texts:
We have created a fuel sensor in our lab with Arduino in order to get fuel data from vehicles. Regarding the code below, I receive an error

  PARSE ERROR: 'attachInterrupt': this function needs to be defined.

Could you please advice?

int pin = 2;
volatile unsigned int pulse;
float volume = 0;
float flow_rate =0;
const int pulses_per_litre = 2000;
int count_pulse;

void setup()
{
    Serial.begin(9600);
    pinMode(pin, INPUT);
    attachInterrupt(0, count_pulse, RISING);

}

void loop()
{
    pulse=0;
    interrupts();
    delay(1000);
    noInterrupts();

    Serial.print("Pulses per second: ");
    Serial.println(pulse);

    flow_rate = pulse * 1000/pulses_per_litre; //

    Serial.print("FUEL FLOW rate: ");
    Serial.print(flow_rate);
    Serial.println(" milliliters per second");

    volume = volume + flow_rate * 0.1; //Time Interval is 0.1 second

    Serial.print("Volume: ");
    Serial.print(volume);
    Serial.println(" milliliters");
}

void count_pulse()
{
pulse++;}


texts:
So I was reading a few questions on drone, and I reach this one.

It said that an ESC is used between the PWM Arduinno's port and the motor. I don't really understand what it means. According to what I understand, a PWM is a varying signal and you just need an electric relay to receive this signal so that the motor receives correct voltage.

However, in other article I read that there are many different ESCs, with firmware and many other parameters to be taken into account. It seems quite overkill for what a relay does, so I am wondering:

What is inside an ESC?
More important, what does it do with PWM signal that could not be achieved with a relay and is essential to command the motor?


texts: Is there a way to retrieve signature from the Voice Recognition module? (Elechouse Voice Recognition V3.1)\

texts:
As of right now, I'm attempting to build a voice recognition system that will respond to what I say accordingly. I have been scouring as to how to retrieve the signature from the voice recognition module's library.

This is my result:

My arduino code that produced the result is below:

#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"

VR myVR(2,3);

uint8_t record[7];
uint8_t buf[64];

#define onRecord (0)
#define offRecord (1)

void printSignature (uint8_t *buf, int len) {
  int i;
  for(i = 0; i < len; i++) {
    if(buf[i] > 0x19 && buf[i] < 0x7F) {
      Serial.write(buf[i]);
  } else {
      Serial.print("[");
      Serial.print(buf[i], HEX);
      Serial.print("]");
    }
  }
}

void printVR(uint8_t *buf)
{
  Serial.println("VR Index\tGroup\tRecordNum\tSignature");

  Serial.println(buf[2], DEC);
  Serial.println("\t\t");

  Serial.print(buf[2], DEC);
  Serial.print("\t\t");

  if(buf[0] == 0xFF){
    Serial.print("NONE");
  }
  else if(buf[0]&0x80){
    Serial.print("UG ");
    Serial.print(buf[0]&(~0x80), DEC);
  }
  else{
    Serial.print("SG ");
    Serial.print(buf[0], DEC);
  }
  Serial.print("\t");

  Serial.print(buf[1], DEC);
  Serial.print("\t\t");
  if(buf[3] >0) {
    printSignature(buf+4, buf[3]);
  }
}

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

  Serial.begin(115200);

  if(myVR.clear() == 0) {
    Serial.println("Recognizer cleared.");
  } else {
    Serial.println("Not find VR Module");
    while(1);
  }

  if(myVR.load((uint8_t)onRecord) >= 0){
    Serial.println("onRecord loaded");
  }

  if(myVR.load((uint8_t)offRecord) >= 0){
    Serial.println("offRecord loaded");
  }
}

void loop() {
  int ret;
  ret = myVR.recognize(buf, 50);

  if(ret > 0) {
    printVR(buf);
  }
}

Any suggestions as to how I'd go in retrieving the signature from this module?

Edit: The module have been trained to recognize my speech saying "two" and is assigned
 the signature 'two'.


texts: Are DAC pins useful for anything besides working with audio?

texts: Whenever I run into information about DAC, it seems to be related to audio processing. Are there any other use cases where DAC might be useful, or have any advantages over regular ADC PWM output on an Arduino?


texts: I have an Arduino Yún, and it only has 16mb flash onboard for the Linux. I was wondering of it is possible to put a bootloader on the flash that uses the sd card as a rootfs? i want to be able to do more projects on it than those that can fit in 16 MB flash.


texts:
LCD screen stops displaying after DC motor starts
I have 3 main components: LCD, thermal resistor, and a DC motor running a fan. The LCD displays the temperature reading from the thermal resistor and then after it hits a certain temperature the motor turns on.

A few seconds after the motor has been turned on the LCD will go blank (but still powered on). I tried connecting a 100uF electrolytic capacitor across between the logic supply pins on the LCD and a 0.47 µF ceramic between the motor terminals.

I did this because i'm assuming since the motor in operation (its commutator) produces voltage/ current "spikes" they can be coupled back through the common power supply. This could provide some immunity against them actually getting to the display driver and interfering with its operation.

What I did kind of helped, but I feel like I am missing something. Any suggestions?

(the link is to the picture of my circuit I quickly made online)


texts: Trying to measure change in light levels over time

texts:
I have two LDR's attached to my Arduino Uno and an RGB LED as an output component. The two LDR's are at different offboard heights in order to see the change in light between them. I want to code on Arduino so that if the difference in light between the two LDR's does not change by a large amount over a 1 hour period (i.e stays similar), it will make the RGB  LED flash. I know that I have to use an if and else statement to do this, but does anyone know how I can code it so that I can achieve the above statement?

Thanks


texts:
hello guys is there someone who can help me with my first project.
its basically about logic circuits.

by using tact switch and pull-up resistor to set the values to logical 1 or 0.
the output can be verified by using a LED as an indicator.
so the code goes like this:

//AND GATE
int pin2=1;         //set pin2=1
int pin3=1;         //set pin3=1

void setup()
{
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
}
void loop()
{
  pin2=digitalRead(2);
  pin3=digitalRead(3);

 if(pin2==1)            //turn led on pin11 when pin2 =1
 {
 digitalWrite(11,HIGH);
 }
 else
 {
 digitalWrite(11,LOW);
 }

 if(pin3==1)          ////turn led on pin12 when pin3 =1
 {
   digitalWrite(12,HIGH);
 }
 else
 {
   digitalWrite(12,LOW);
 }

//TRUTH TABLE OF AND

  if(pin2 && pin3)
  {
    digitalWrite(4,HIGH);
  }
  else
  {
  digitalWrite(4,LOW);
  }
}

//OR GATE
int pin2=1;
int pin3=1;

void setup()
{
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
}
void loop()
{
  pin2=digitalRead(2);
  pin3=digitalRead(3);

 if(pin2==1)
 {
 digitalWrite(11,HIGH);
 }
 else
 {
 digitalWrite(11,LOW);
 }

 if(pin3==1)
 {
   digitalWrite(12,HIGH);
 }
 else
 {
   digitalWrite(12,LOW);
 }

//TRUTH TABLE OF OR

  if(pin2 || pin3)
  {
    digitalWrite(4,HIGH);
  }
  else
  {
  digitalWrite(4,LOW);
  }
}

//NAND GATE
int pin2=1;
int pin3=1;

void setup()
{
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
}
void loop()
{
  pin2=digitalRead(2);
  pin3=digitalRead(3);

 if(pin2==1)
 {
 digitalWrite(11,HIGH);
 }
 else
 {
 digitalWrite(11,LOW);
 }

 if(pin3==1)
 {
   digitalWrite(12,HIGH);
 }
 else
 {
   digitalWrite(12,LOW);
 }

//TRUTH TABLE OF NAND

  if(!(pin2 && pin3))
  {
    digitalWrite(4,HIGH);
  }
  else
  {
  digitalWrite(4,LOW);
  }
}

can you guys help me to run this in one sketch by using tact switch  to select the logic gate to be tested or run? thank you in advance


texts:
This is my first circuit ever (!) and so I'm hoping that I'm just making an easy-to-spot rookie mistake. I am trying to power an Arduino Due with a 9V battery and then have the Due in turn power a red LED. No blinking. No sketchpad/C program flashed to the chip. Just straight up electricity:

When I connect the battery, several things happen:

There is a green power LED on the Due that lights up; and
Right next to it is an orange LED (on the Due itself) that blinks every few seconds (not sure what this LED is or what the blinking means, but providing that detail for good measure); and
The red LED on the breadboarrd does not light up

This is a 2V/15mA LED, and as you can see I'm powering it from the 5V power jack on the Due. So a 220 ohm resistor should be perfect for it (R = (Vs - V) / I = (5V-2V) / .015A ~= 220 ohms).

So, for the first time ever, I busted out my multimeter, set it to the voltage setting, and started testing the circuit. First I tested Vin and GND on the Due (that is, the connection between the battery and the Due), and the multimeter lit up and hovered (correctly) around 5V. So far so good. Next I tested the power and ground connections on the breadboard power rails (indicated in green above). Again, the multimeter reported a roughly 5V power supply. Then I tested the connection from the power rail to the row (purple in pic above) feeding power to the resistor, and to my surprise, the multimeter reports no power at those two purple locations.

My understanding was that the power rail will power the entire column its connected to (in my case, the left-most column), and then any rows connecting to a power rail/column will also be powered. So I'm not understanding why there's voltage on my power rail/column, but not on the wire connecting my power rail to the resistor. Any ideas?

Update:

Here is my corrected circuit per initial feedback. Please note this is still not working, but I think I'm getting close:


texts: Why send my Arduino sometime Hex and sometimes the wrong?

texts:
Hi i have an Arduino mega 2560 i send data from the Arduino over USB to PC. That works when i test a simple Serial.print("Hello"); but that is not that what i need. I send a timestamp as a longe Value and the databyte as a short Value. When i send the timestamp as BIN like that:

      //Initialisisation

const int RX = 0;
const int TX = 1;
const int RX1 = 19;
const int TX1 = 18;
unsigned long currentMillis;

void setup()
{
  pinMode(RX, INPUT);   //Readpin for USB
  pinMode(TX, OUTPUT);  //Writepin for USB
  pinMode(RX1, INPUT);  //Readpin for bus
  pinMode(TX1, OUTPUT); //Writepin for für bus

  Serial.begin(38400);   //open interface for USB
  Serial1.begin(4800);   //open interface for bus

  while (!Serial & !Serial1 &! Serial2)
  {
    ;//wait for serial port connect.
  }
}

void loop()
{
  //Ask if the timestamp over 8 hours, when yes,
  //send the time to the pc and reset currentMillis.
  currentMillis = millis();
  if (currentMillis >= 28800000)  //milli() 8 hours is a 4 byte  timestamp 28.800.000 millisec.
  {
    unsigned long timestamp = currentMillis;
    sendBinaryTime(timestamp);
    currentMillis = 0;
  }//end if

  //if the businterface available, read a byte
  //and send it with the timestamp to the PC.
  //If the businterface not available send an error.
  //short incomingByte = Serial1.read();
  //sendBinaryValue(incomingByte);
  if(Serial1.available()>0) //if the bus (serial1) available?
    {
      short incomingByte = Serial1.read(); //read the next byte from _rx_buffer
      sendBinaryValue(incomingByte);
      sendBinaryTime(currentMillis);   //sendBinary send a long over the bus
    }//end if
}//end Loop()

//Methods for sending long values

void sendBinaryValue(short incomingByte)
  {
    int temp = (incomingByte & 0xFF00)>>8;
    Serial.println(temp, HEX);
    temp = (incomingByte & 0x00FF);
    Serial.println(temp, HEX);
    return;
  }

void sendBinaryTime(unsigned long currentMillis)//send milliseconds after every byte
{
  int temp = (currentMillis & 0xFF000000)>>24; //send 16 bit of the low value
  Serial.print(temp, BIN);
  temp = (currentMillis & 0x00FF0000)>>16;      //send 16 bit of the high value
  Serial.print(temp, BIN);
  temp = (currentMillis & 0x0000FF00)>>8;
  Serial.print(temp, BIN);
  temp = (currentMillis & 0x000000FF);
  Serial.print(temp, BIN);
  return;
}

All is fine i haven´t any error. But i want the timestamp as DEC so i have changed the code to:

       void sendBinaryValue(short incomingByte)
 {
   int temp = (incomingByte & 0xFF00)>>8;
   Serial.println(temp, HEX);
   temp = (incomingByte & 0x00FF);
   Serial.println(temp, HEX);
   return;
 }

void sendBinaryTime(unsigned long currentMillis)
{
 int temp = (currentMillis & 0xFF000000)>>24;
 Serial.print(temp, DEC);
 temp = (currentMillis & 0x00FF0000)>>16;
 Serial.print(temp, DEC);
 temp = (currentMillis & 0x0000FF00)>>8;
 Serial.print(temp, DEC);
 temp = (currentMillis & 0x000000FF);
 Serial.print(temp, DEC);
 return;
}

Now when i look on the serial monitor i get an error.
Here you can see it:

I send an A as ASCII sign that must be Hex 41 and i receive a Hex 5 but why? When i send the timestamp as BIN i get the 41 and haven´t any problem.

I hope someone can help me with friendly wishes sniffi


texts: Using same GPIO pins to control multiple stepper drives

texts:
I have an Arduino Mega 2560 and I want to control four 23-frame steppers same speed/direction for a conveyor application. I want these to be synchronized exactly as possible for smooth operation.

Can four TB6600 drivers be daisy chained to the same Arduino GPIO pins?

Is there a limit to how many number of drivers I can daisy chain?

I'm wondering about current draw from the 5 volt Arduino GPIO, spread out over many drivers.

Thanks for your help!
Bob


texts: I need to incorporate a battery monitor using a 10 led bar graph. I am powering the arduino with a 7.4(though it reads 7.67) V  lithium polymer battery through the arduino`s power jack. The goal is to monitor that battery. How would I go about doing this? I have a LM3914 driver to use if I want but I am clueless as to what to do.


texts: nodeMCU - when DC is active on pin the do this

texts:
i have a nodeMCU v3(esp8266)
and what i want is: when i send  DC 5v or 3v to a pin=D1 (idk if its possible to send 5v directly to pin) then to activate the D0 for 20Seconds

like this:

 if (D1==Sends signal){
    digitalWrite(pinD0, HIGH);
      delay(20000);  //pinD0 is active for 20 seconds

  }else{
     digitalWrite(pinD0, LOW);

  }


texts:
To keep the question short:

I'm trying to burn a bootloader on my Arduino Uno using an Arduino Uno. Could someone please tell me the pin connections? Thanks.


texts: Can't turn off fan using PWM and analogWrite(x, 0)

texts:
I'm trying to make PWM Signal Generator with Arduino Uno.
I'm trying to control 230V 50hz "NRG118" combi boiler fan.  The fan powered by AC and have 3pins for PWM control. "vcc,gnd,pwm" Wired them to arduino "5v, GND, 11" pins.
I can control the card on the arduino "0to100% with a simple code below but I can't turn it off.
I tried digitalWrite nothing changed. Tried different pins 5-6-9-11 nothing changed. Tried to wire gnd+vcc to outsource powersuply nothing changed.
Also I have a simple PWM generator "HW-723 XY-LPWM PWM Signal Generator Module". The "HW-753" can control the fan without any other component but it may have builtin special component like a NPN but im not sure about it.
In description I found this and maybe its a requirement but I have no idea about electronic components:
"The PWM output pin on the microcontroller drives an NPN MMBT3904 type transistor which in turn drives the PWM output pin of the module.  The transistor has a series 1K resistor tied to VIN+, so the PWM signal will swing between ground and the module supply voltage on the VIN+ pin."
With the HW-753; at startup the fan is not running but when I wire to my arduino it starts with 100% power and when i set "analogWrite(x, 0)" dutycycle reducing but fan still running at %1 speed and I read 0.07volt with multimeter on "PWM+GND" pins.
Most people can not run, I cant stop.... It's killing me people...
What am I doing wrong?
void setup() {
  pinMode(6, OUTPUT);
}
void loop() { //the code only for test. Using loop is dumb.
  //digitalWrite(6, LOW);
   analogWrite(6, 0);
   delay(5000);
}


texts: File Upload and sending Form data to the ESP using HTTP POST

texts:
i want to upload a file from my pc to the esp2966 webserver with sd card. all works fine.
But i want to transmit some extra data from a input form field.

The Upload works good. in the browser console i can see that the firstname is transmitted.
But in the server.arg are no arguments received.
What is wrong?

Here is my Code:

server.on("/fupload",  HTTP_POST,[](){ server.send(200);}, handleFileUpload);
...
..
.
void handleFileUpload(){
  String firstname = server.arg("vorname");
  Serial.println("Vorname: " +firstname);
  HTTPUpload& upload = server.upload();
  if (upload.status == UPLOAD_FILE_START) {
    String filename = dir_name +"/" + upload.filename;
    uploadFile.open((char *)filename.c_str(), FILE_WRITE);
     } else if (upload.status == UPLOAD_FILE_WRITE) {
      if (uploadFile.isOpen()) {
        uploadFile.write(upload.buf, upload.currentSize);
        else if (upload.status == UPLOAD_FILE_END) {
          if (uploadFile.isOpen()) {
            uploadFile.close();
            webpage = "";
            append_page_header();
            webpage += F("
File was successfully uploaded
");
            webpage += F("
Uploaded File Name: "); webpage += upload.filename+"
";
            webpage += F("
File Size: "); webpage += file_size(upload.totalSize) + "
";
            webpage += F("&lArr;[Back]

");
            server.send(200,"text/html",webpage);
          }
        }
      }
   }
}

here the html for upload

<FORM action='/fupload' method='post' enctype='multipart/form-data'>
  <input type="file" name="Datei" id="fileInput">
  <input type="text" name="vorname" value="TEST">
  <button type='submit'>Upload File</button>
</FORM>

EDIT:
if i change this line

server.on("/fupload",  HTTP_POST,[](){ server.send(200);}, handleFileUpload);

to this:

server.on("/fupload", HTTP_POST, handleFileUpload);

Then the server.arg works but the upload does not work.
Why? How can i solve this problem?


texts: MKR WIFI 1010 Providing 3.3V to breadboard

texts:
The Arduino MKR WIFI 1010 product page says "The microcontroller on the MKR WIFI 1010 runs at 3.3V, which means that you must never apply more than 3.3V to its Digital and Analog pins. Care must be taken when connecting sensors and actuators to assure that this limit of 3.3V is never exceeded. Connecting higher voltage signals, like the 5V commonly used with the other Arduino boards, will damage the MKR WIFI 1010."

and yet it only has a 5V pin. I have a sensor that requires a 3.3V pin so I'm guessing my only option is to use a Logic Level Converter.

My question is if the MKR Digital and Analog pins can only take 3.3V, why is there only a 5V pin instead of a 3.3V pin to connect to a breadboard?


texts: Serial Hangs with multiple PN532 nfc reader and a TCA9548A

texts:
I am trying to use multiple PN532 reader. I have put all my readers on a multiplexer (TCA9548A).

The script works well, but when I move my tags on readers sometimes the serial says to me there is an error on reading tag like that : Read failed [number] or like Error. Failed read page [number] where [number] is a Integer.

And sometimes the serial completely hangs and not sends anything anymore, I have to reset the arduino by pressing the reset button.

Other information :

Arduino : My arduino is a Mega.

Here is my code :

#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>

#define TCAADDR 0x70

#define RST_PIN 2

PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);

int NB_NFC_READER = 4;

void tcaselect(uint8_t i)
{
  if (i > 7) return;
  Wire.beginTransmission(TCAADDR);
  Wire.write(1 << i);
  Wire.endTransmission();
}

void setup(void)
{
    while (!Serial);
    delay(250);

    Wire.begin();

    // Serial.begin(115200);
    Serial.begin(9600);

    //Serial.println("NDEF Reader");

    /**Initialisation des lecteurs NFC*/
    for(int i = 0 ; i < NB_NFC_READER ; i++)
    {
      //Serial.println("CONFIGURATION DU READER N° " + String(i));
      tcaselect(i);
      nfc.begin();
    }

    pinMode(RST_PIN, INPUT);
    digitalWrite(RST_PIN, HIGH);

    Serial.println("SETUP OK !");
}

void loop(void)
{
  String tag0;
  String tag1;
  String tag2;
  String tag3;

    for(int i = 0 ; i < NB_NFC_READER ; i++)
    {
      //Serial.println("FOR INDEX : " + String(i));
      tcaselect(i);
      if (nfc.tagPresent(100))
      {
          NfcTag tag = nfc.read();
          //tag.print();
          if(i == 0)
          {
            tag0 = tag.getUidString();
          }
          if(i == 1)
          {
            tag1 = tag.getUidString();
          }
          if(i == 2)
          {
            tag2 = tag.getUidString();
          }
          if(i == 3)
          {
            tag3 = tag.getUidString();
          }
          //Serial.println("LECTURE SUR LECTEUR " + tag.getUidString());
          delay(100);
      }
    }
    Serial.print("[");
    Serial.print("{\"tag0\":");Serial.print("\"");Serial.print(tag0);Serial.print("\"},");
    Serial.print("{\"tag1\":");Serial.print("\"");Serial.print(tag1);Serial.print("\"},");
    Serial.print("{\"tag2\":");Serial.print("\"");Serial.print(tag2);Serial.print("\"},");
    Serial.print("{\"tag3\":");Serial.print("\"");Serial.print(tag3);Serial.print("\"}");
    Serial.println("]");
}

Thank you for reading, I hope someone will find why the serial freeze like that.


texts: How to get a specific value from an unknown number of JSON representations?

texts:
I am using ArduinoJson and ESP8266HTTPClient.
Say I have a DynamicJsonDocument that has an unknown number of entries with information on different persons:
[
    {
        "ID": "12345",
        "name": "John Smith",
        "Address": "Street 1"
    },

    .
    .
    .

    {
        "ID": "00345",
        "name": "Paul Anderson",
        "Address": "Street 2"
    }
]

I would like to somehow store the values associated with the key "name" for all the different persons. For example, have something like:
String name1 = "";
...
String nameN = "";

.
.
.

Serial.println(name1);
...
Serial.println(nameN);

To print a list of all the names:
John Smith
Paul Anderson

The only information of the JSON I have beforehand is the keys each entry will have. I do not know how many entries there will be.
How can I go about this?
EDIT: Why I want to do this:
I am using the ESP as a client to get information from a server in the form of a JSON similar to what I wrote above. At the same time, I am serving a simple HTML website by doing server.send(200, "text/html", HTML_code); using the ESP as an AP. I was able to just cram the whole JSON into the HTML as text, but I would like to just have specific information from the JSON, as explained above.
I am aware what I am doing is far from elegant or the "correct way to do it", but I am learning all of this, so any criticism and help is more than welcome :)


texts: Odd symbols in ESP8266 responses to AT commands

texts:
I used the code below to control an ESP8266.  I am getting some unknown symbols in the responses.

#include <SoftwareSerial.h>
const byte rxPin=2;
const byte txPin=3;
SoftwareSerial ESP8266( rxPin, txPin);

void setup() {
  Serial.begin(115200);
  ESP8266.begin(115200);
  delay(1000);
  // put your setup code here, to run once:

}

void loop() {
  Serial.println("sending an AT command");
  ESP8266.println("AT");

  delay(100);
  while(ESP8266.available())
  {
    String inData = ESP8266.readStringUntil('\n');
    Serial.println("Got Response:" + inData);
    delay(1000);
      ESP8266.println("AT+RST");
    }
  // put your main code here, to run repeatedly:

}

The unknown symbols are shown in the screen shot.

What might the problem be?


texts: How to switch on and off an HD44780 LCD Display?

texts:
I have an LCD Display HD44780 model and I was reading his datasheets

I saw the it has the functionality to be switched on/off as stated:

  Display on/off control: D = 0; Display off // C = 0; Cursor off // B = 0;
  Blinking off

and by continue reading it states:

Then he states again:

Display On/Off Control

  D:  The display is on when D is 1 and off when D is 0. When off, the
  display data remains in DDRAM.

But I can't reaaly understand what I fisically need to do, can anyone help me out to better understand?

EDIT:
For better clarify myfinal goal is to completely (power OFF) the LCD screen, I have some NPN transistors and if this would be the best solution, how about the wiring? do I have only to stop suppying VDO?


texts:
I want keep my RTC1307 always updated with my server, so I created this code to first search the time on the server then passes to getServerTime() function to divide it and set in the RTC. I use the rtc.adjust() to adjust my watch.

Problem: My watch is getting wrong, this is set 2165/165/165 165:165:85. I think the problem is in defining the time in rtc.adjust(), I'm going as follows:

//tempDate -> May 19 2015
//tempHour -> 09:25:14
rtc.adjust(DateTime(tempDate, tempHour));

Does anyone know the cause of this error?

#include <Ethernet.h>
#include <SPI.h>
#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 rtc;

byte server[] = { 192, 168, 0, 8 };
byte ip[] = { 192, 168, 0, 237 };
byte mac[] = { 0xDE, 0xAD, 0xAD, 0xEF, 0xFE, 0xED };

void setup() {
    Ethernet.begin(mac, ip);
    Serial.begin(9600);
}

void loop() {
    getServerTime(getSiteData());
    DateTime now = rtc.now();

    Serial.print(now.year(), DEC);
    Serial.print('/');
    Serial.print(now.month(), DEC);
    Serial.print('/');
    Serial.print(now.day(), DEC);
    Serial.print(' ');
    Serial.print(now.hour(), DEC);
    Serial.print(':');
    Serial.print(now.minute(), DEC);
    Serial.print(':');
    Serial.print(now.second(), DEC);
    Serial.println();
    Serial.println();
    delay(5000);

}

char * getSiteData()
{
    EthernetClient http;
    unsigned char startRead = 0, i = 0;
    char inString[50];

    if (http.connect(server, 80)) {
        http.println("GET /util/date.php HTTP/1.1");
        http.println("Host: ");
        http.println("Connection: close");
        http.println();

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

                if (c == '<' )
                    startRead = 1;

                else if (startRead) {

                    if (c != '>') {
                        inString[i] = c;
                        i++;
                        inString[i] = '\0';
                    } else {
                        startRead = 0;
                        http.stop();
                        http.flush();
                        return inString;
                    }
                }
            }
        }
        Serial.println(inString);
        http.stop();
        http.flush();
    }
    else
        Serial.println("Tentativa de conexão falhou. Sem internet ou servidor inacessivel");
}

//May 19 2015-09:17:24
void getServerTime(char* siteData)
{
    char *tempDate, //May 19 2015
        *tempHour; //09:17:24

    tempDate = strtok(siteData, "-");
    tempHour =  strtok(NULL, "-");

    rtc.adjust(DateTime(tempDate, tempHour));

}


texts: Arduino Micro interference between analog inputs

texts:
I'm building a MIDI controller with the Arduino Micro, hooking a bunch of knobs up to the analog inputs. Currently, I'm getting analog in 9 being influenced by analog in 10: analogRead(9) returns a number close to analogRead(10) and doesn't give the voltage that I'm reading with a multimeter.

What could be causing this interference?


texts: Advice on cabling, packaging and connectors for 12v light project

texts:
My project is to have a 12V solar LED strip lighting system throughout my apartment. This has 6 individual lights, with 5 white and 1 RGB = 8 channels.

I've got the whole setup working on my breadboard. Now it's time to transfer it to a "live" setup. Since it's my first such project, I'm looking for any and all recommendations on cabling and connectors to deal with reliability, isolation, modularity, aesthetics and of course safety.

Schematically, it all looks something like this

solar panel------\
                  charge controller--5v regulator--arduino--mosfets x 8--\__lights
12v battery_fuse_/                  \____________________________________/

So I have questions such as:-

should I use a prototype shield, or a discrete pcb?
do the MOSFETs (RFP30N06LE) need a heatsink, and any recommended unit?
what connectors are recommended?
any suggestions on box/packaging for the above?
wire gauge? Maximum run is 4m to the furthest light.

And any other hints, tips and suggestions greatly appreciated. Bonus appreciation for amazon links to the parts :-)

update
The breadboard is simply the mosfets, each with a current limiting resistor on the gate. The lights range from 8W to 40W. I will generally have them dimmed using PWM.


texts:
I found a code from Astronomica Messier that allows to activate a servo from a Gyroscope MPU 6050 change in direction. I followed the wiring and uploading correctly. The thing is that the MPU is initializing but the connection is failing. Could you help me please to figure out whats happening here? I'm using a GY-86, an Arduino Nano and a Micro Servo 9g. Here's the code. Thank you.

#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Servo.h"

MPU6050 mpu;
int16_t ax, ay, az;
int16_t gx, gy, gz;
Servo servo1;

int val1;
int prevVal1;

void setup()
{
Wire.begin();
Serial.begin(38400);
Serial.println("Initialize MPU");
mpu.initialize();
Serial.println(mpu.testConnection() ? "Connected" :
"Connection failed");
servo1.attach(9);
}

void loop()
{
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
val1 = map(ax, -17000, 17000, 120, 10);
if (val1 != prevVal1)
{
servo1.write(val1);
prevVal1 = val1;
}
delay(50);
}


texts: How would I go about scrolling a name across a LoL shield with a potentiometer?

texts:
I am fairly new to Arduino programming and I have been set with the task of scrolling my name across a LoL shield with a potentiometer. I really don't have any idea how to do this and when I tried to look it up online there is nothing for such a task. I did look at the library references on the LoL shield website but I couldn't make sense of it.

What I did find was a LoL shield sequencer to allow animation on the LoL shield and I figured that might help but I don't know how to use that code to create a scrolling effect with a potentiometer.


texts: Can we call GPRS HTTP request asynchronously in Arduino?

texts: Usually GPRS modules (SIM800,900, A6, etc) that used with arduino are called in synchronous way in HTTP (GET/POST) request. It takes more than 10 seconds in most times and this makes the system very slow. Is there a way to use them (libraries or the module) asynchronously (or is there any alternatives) and perform these request in background while main business is being done?


texts:
I am trying to run a small 3v motor with a Keyestudio MEGA 2560(which is the same as the Arduino MEGA 2560). I am getting a consistent 5 volts everywhere I check with a multimeter. The voltage drops to 0.01-0.05 once I connect the motor. The motor runs once it is connected directly to the Arduino's 5v output pin. The motor draws about 600mA consistently when we connect it directly to 5v.
My code is rather basic, which just sends voltage out pin 5.  I am not using any shield. controlling the speed is not my main concern here, though later on in my project I would like the motor to be able to reverse as well.
I found this circuit diagram in "Arduino for dummies," and found this same diagram on many other websites too.
void setup() {
  pinMode(5,OUTPUT);
}

void loop() {
  digitalWrite(5,HIGH);
}

simulate this circuit – Schematic created using CircuitLab


texts: Why does my wired button always read HIGH?

texts:
I have made a simple Arduino program that uses a potentiometer to dim a LED.

This program also makes a second LED blink.

Finally, I have added a button that controls a third LED; this part of my program does not work: the 3rd LED is always lit as the button always reads HIGH.

Here is the code:

//sensePin is wired up to the FSR
int sensePin = 2;

//this is wired up to an LED
int ledPin = 9;

//Wired up to a button
int inputPin = 1;

int val = 0;

//I was broed so added the default Blink
int ledPinX = 13;

//Wired up to a second LED
int ledPinY = 7;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(inputPin, INPUT);
  pinMode(ledPinX, OUTPUT);
  pinMode(ledPinY, OUTPUT);
  val = digitalRead(inputPin);
}

void loop() {
  if (val == HIGH){
    //This should ask "If your button is pressed, then do the code below
    digitalWrite(ledPinY, HIGH);
    //but for some reason the light is always on. I've tried it with more than one button
  }
  else if(val == LOW){
    digitalWrite(ledPinY, LOW);
  }
  int value;

  /*
 The rest of this stuff works. Well, it did before adding in the button. Now the FSR acts as a digital input. Please help.
   */
  value = analogRead(sensePin) / 4;
  analogWrite(ledPin, value);
  digitalWrite(ledPinX, HIGH);
  delay(500);
  digitalWrite(ledPinX, LOW);
  delay(500);
}

What did I do wrong in this code?

EDIT:: diagram and pic at: instagram.com/p/m3AmHWmp4e


texts: Is there a radar - like sensor that can tell me the distances of multiple things around the sensor?

texts:
I'm trying to develop something that requires accurate distance measurement of objects around the center of the contraption. However, I cannot find any way to achieve this other than using a bunch of infrared distance sensors. Really, I'm looking for something that costs at most $200 and is compatible either with arduino, PC, or raspberry pi.

This may not be the place for this, if not, please inform me.

Thanks in advance!


texts: Send and receive text between Arduino Mega 2560 and C# via ENC28J60

texts: I'm working on an Arduino project that sends and receives text to/from a C# application via ENC28J60 in a LAN network. Whenever C# sends a request to Arduino (In text), Arduino responds to it by sending also a text. What is the best way to do this? I'm newbie in network programming (Or whatever it's called). Thanls in advance :)


texts: Need Help to Select Microcontroller ?? Help

texts:
i am doing a project which has to run in side a garage to control water levels in sump pit as well as in overhead tank . also schedule running of  pumps.

i have to run 5 pumps  (two for ground water to sump pit , three for sump pit to  over head tank) check two levels also need to check when pump goes on the water is flowing or not if not try another pump

the micro controller should last at least two years .

the temperature inside garage where micro controller board will be kept will go to 47 centigrade in summer to 15 centigrade in winter .

i see many options :

1.arduino uno

2.arduino uno from sparfu and adafruit

3.Sparkfun Arduino Fio

4.SparkFun Arduino Pro Mini 328

5.Adafruit Metro Mini 328

6.Adafruit METRO 328

7.Particle Photon

what whould i use ?


texts: Arduino Uno R3 Bluetooth Shield is not discovering in any of the device

texts:
I have a problem regarding Seeedstudio Bluetooth shield http://www.seeedstudio.com/depot/Bluetooth-Shield-p-866.html

I can't detect its presence by any other devices.

The code I uploaded to Arduino is a standard example for slave device from the library:

#include <SoftwareSerial.h>   //Software Serial Port
#define RxD 6
#define TxD 7

#define DEBUG_ENABLED  1

SoftwareSerial blueToothSerial(RxD,TxD);

void setup()
{
    Serial.begin(9600);
    pinMode(RxD, INPUT);
    pinMode(TxD, OUTPUT);
    setupBlueToothConnection();
}

void loop()
{
    char recvChar;
    while(1)
    {
        if(blueToothSerial.available()){//check if there's any data sent from the remote bluetooth shield
            recvChar = blueToothSerial.read();
            Serial.print(recvChar);
        }
        if(Serial.available()){//check if there's any data sent from the local serial terminal, you can add the other applications here
            recvChar  = Serial.read();
            blueToothSerial.print(recvChar);
        }
    }
}

void setupBlueToothConnection()
{
    blueToothSerial.begin(38400); //Set BluetoothBee BaudRate to default baud rate 38400
    blueToothSerial.print("\r\n+STWMOD=0\r\n"); //set the bluetooth work in slave mode
    blueToothSerial.print("\r\n+STNA=SeeedBTSlave\r\n"); //set the bluetooth name as "SeeedBTSlave"
    blueToothSerial.print("\r\n+STOAUT=1\r\n"); // Permit Paired device to connect me
    blueToothSerial.print("\r\n+STAUTO=0\r\n"); // Auto-connection should be forbidden here
    delay(2000); // This delay is required.
    blueToothSerial.print("\r\n+INQ=1\r\n"); //make the slave bluetooth inquirable
    Serial.println("The slave bluetooth is inquirable!");
    delay(2000); // This delay is required.
    blueToothSerial.flush();
}

I've uploaded it to Arduino UNO, connected the shield.

LED marked as D1 is blinking green, and D2 is switched off. The device is not detected by none of the  devices I've tried

Please Help Me


texts: Using union to return a range of bits from a data frame: wrong approach?

texts:
I'm working on an adaptation of Jason Leyrer's Guitar Hero Library for Arduino.  My version is for a DJ Hero controller, and I've also borrowed some code from this Arduino forum thread: topic=120527 (sorry can't post links yet).

The protocol is i2c and I am successfully reading data from it, however I'm not 100% sure what to do with the data.

The buttons are fine, as they are mapped to just one bit in a given byte.  However the other controls are a combination of 4, 5 and 6 bit longs.

The format according to Wiibrew is like so:

BE is for Euphoria button
CS : Crossfade Slider, lower is left and upper is right
SX and SY are the black analog stick.
ED is the Effect Dial
RTT is the turntable on the right as a 6-bit signed integer (positive = CW; negative = CCW)
RBG,RBR,RBB are the Green, Red and Blue buttons on the right
LTT is the turntable on the left as a 6-bit signed integer (positive = CW; negative = CCW)
LBG,LBR,LBB are the Green, Red and Blue buttons on the left

I'm trying to do this:

 signed long DJ_ED()
{
  pack5 ED;
  ED[0] = (DJ_buf[3] >> 5) & 1;
  ED[1] = (DJ_buf[3] >> 6) & 1;
  ED[2] = (DJ_buf[3] >> 7) & 1;
  ED[3] = (DJ_buf[2] >> 5) & 1;
  ED[4] = (DJ_buf[2] >> 6) & 1;

  return ED;
}

Where pack5 is the following:

#define packet5
union pack5
{
   signed long value;
   int ints[5];
};

but I'm getting the following error:

no match for 'operator[]' (operand types are 'pack5' and 'int')

What am I doing wrong?


texts: I would like to set a stopwatch timer that will determine how long an input is in a certain state before changing. I want to set it so that, depending on the output my code executes one of 2 switch cases. But my trouble comes in on setting a timer. Is there a function I could use? Or a method that somebody knows? The time that the input will be for each case is not fixed so I cannot use a delay.


texts:
#include <RTClib.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x27 for a 16 chars and 2 line display
int nowHr, nowMin, nowSec;
RTC_DS3231 rtc;
const int pin_contact= 6;
const int buzzer = 9;
//first alarm
int h1=15;
int m1=51;
int s1=0;

void timeScreen() {              // function to display Date and time in LCD screen

  DateTime now = rtc.now();             // take rtc time and print in display
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Time:");
    lcd.setCursor(6, 0);
    lcd.print(nowHr = now.hour(), DEC);
    lcd.print(":");
    lcd.print(nowMin = now.minute(), DEC);
    lcd.print(":");
    lcd.print(nowSec = now.second(), DEC);
    lcd.setCursor(0, 1);
    lcd.print("Date: ");
    lcd.print(now.day(), DEC);
    lcd.print("/");
    lcd.print(now.month(), DEC);
    lcd.print("/");
    lcd.print(now.year(), DEC);
    delay(500);

}

void setup()
{
Wire.begin();
   //rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));            // uncomment this to set the current time and then comment in next upload when u set the tim
  rtc.adjust(DateTime(2021, 03, 27, 15, 50, 50));                // manual time set
  lcd.backlight();
  lcd.begin(16, 2);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("hello");                                      // print a messege at startup
  lcd.setCursor(0, 1);
  lcd.print("world");
  delay(1000);
  timeScreen();
  delay(3000);
  lcd.clear();
 // Set buzzer - pin 9 as an output
    pinMode(pin_contact, INPUT);

 // Set buzzer - pin 9 as an output

    Serial.begin(9600);
}

void loop()
{
   timeScreen();
   lcd.backlight();
   at8am();
   Serial.begin(9600);
}

void at8am() {                      // function to start buzzing at 8am

  DateTime t = rtc.now();

  if (int(t.hour()) == h1 && int(t.minute()) == m1    ) {
        /////////////////////////////////////////////////////
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Time for ");
        lcd.setCursor(0, 1);
        lcd.print("breakfast");
   stopbuzzer();
         delay(5000);

        /////////////////////////////////////////////////////

      }
}

void stopbuzzer ()
{
   int buzzer_state=1;

  int stare_contact = digitalRead(pin_contact);

  if (stare_contact == HIGH && buzzer_state==1)
   {
buzzer_state=0;
   }

    digitalWrite(buzzer,buzzer_state);

    }

Hello !
My intention is to stop an alarm, after a push button is pressed. In this code, a buzzer is ringing, when if condition is accomplished, and it stops when push button is pressed, but not forever, it keeps going to ring as long if conditions are available. How can the buzzer stop ringing after the push button is pressed?


texts:
first of all I have to say that this is my first Arduino thing. I'm trying to connect a k-type termocouple to my Arduino using an LM2904 Oamp, Yes I know that this is not the best solution but is the only that I have right now due to the pandemic situation, that I can't get a dedicated module as an MAX6675
This is what I have done:

note: The Grnd symbol next to 2.6k resistor is a handwritten error, its not connected in the circuit
my problem is that with this circuit I'm having 3.7V on the arduino analog input even before connect the termocouple. After connect it, the read is about 2.6V and it starts to increase as expected when heat is applied.
My problem is if I have 2.6V for 32°C for temperatures over 200°C I will have more than 5V. Any help with this?


texts: Can I connect a PWM pin on one Arduino to an analog input on another?

texts:
I was considering several different ways to send simple data from one Arduino to another when I though, why not connect a PWN pin of one Arduino to the analog pin on another?  I could send simple messages for one to the other by setting different values on the PWM pin.  This seems like it would work, except for the fact the the PWM pins mimic voltages with pulses.

Is this a reliable way to link two Arduinos, If I only want to communicate 4 states?  Also, will I need to include some additional components in the connection (resister, capacitor, etc.)

All it needs to do is send a 2v pulse for yes and a 5 v pulse for no. It needs to do this about 6 times an hour.


texts: What happens if device sends data to arduino over serial port (UART) and arduino is unable to read it

texts:
Suppose delay(10000) function is executed, so Arduino cannot do any other work.

  During this time if the other device sends the data to arduino what
  will happen ?


texts: How to protect sensors used on atheletes?

texts:
I'm working on a project were we are trying to attach accelerometers to soccer players and capture various aspects of movement data.  Breadboarded circuits are coming along nicely and I'm now looking for how to best protect sensors we can mount on players.  (All wire at the moment unfortunately - BT next.)

Although I can find ways to protect the sensor for sensor damaging impact (we are essentially interested in player impacts with the ball or ground) there are other aspects of protection I'm not sure about.  Any recommendations on how to protect from moisture without increasing bulk too much, minimizing cushioning which could affect the data and of course avoid adding anything that could injure the player?  I have come across other examples of movement studies, but they have been by musicians or other situations that do not include outdoor weather and sweaty bodies.


texts: ATtiny85 soft-latching, and sensor-waking: Are multiple switches differentiable by pin change interrupt?

texts:
I am using a vibration switch with a pin change interrupt on an ATTiny85 to wake the processor and run some code when the vibration switch grounds an input pin. The circuit is battery-powered, so sleep mode is important. I would now like to add another input switch (momentary pushbutton) between an internal pullup on the ATtiny and ground to use as a soft latching switch to accomplish on/mode/off (power-on/case-selection/power-off). I'd like the vibration-wake-sleep code to be one of the cases selectable by the pushbutton. The ATtiny85 has one hardware interrupt (pin2 aka INT0), and the rest are pin change interrupts available on the other I/O pins.
After reading around, my understanding is that the pin change interrupts cannot be separated to run pin-specific code, as they all trigger the same pin change interrupt effect. Is that correct?
To put it another way, do I need to put my pushbutton on the hardware interrupt pin, or can I put it on any old I/O pin and still be able to use the vibration switch on another I/O pin only when I select that mode, without it triggering the same effect as the pushbutton every time there's a vibration? Or is there a better way? I'm trying to minimize the number of components, as this is a space-constrained project. Thanks!


texts: Matlab too many input arguments using csvread


texts:
I am having a problem with pins of Arduino Uno. I have connected a LED to one of the analog pins (A0), and I want to light up the LED with different intensinty.

int ledPin = A0;
void setup() {
 // put your setup code here, to run once:
 pinMode(ledPin,OUTPUT);

}

void loop() {
 // put your main code here, to run repeatedly:
 analogWrite(ledPin,500);
}

The point is that even if I change the value of analogWrite, the LED lights up always with the same intensity.


texts: M0 pro: SPI communication, code works on Uno, but not in M0. Using ICSP port

texts:
I am trying to establish a communication between a sensor and a M0 -pro using SPI. The code :

    #include <SPI.h>

    unsigned int result  = 0;
    void readAngle();

    void setup() {
      Serial.begin(9600);
      SPI.setBitOrder(MSBFIRST);
      SPI.setClockDivider(SPI_CLOCK_DIV8); //sets the clock speed for data transfer, slowed down 8 times
      SPI.setDataMode (SPI_MODE1);

      digitalWrite(11,HIGH);
      pinMode(11,OUTPUT);

      SPI.begin();
      SerialUSB.println("First Try");
}

    void loop() {
      readAngle();
      SerialUSB.println(result);
      delay(500);

}

    void readAngle(){
        digitalWrite(11,LOW); //Turn SS on, start communication
        result = SPI.transfer16(0xFFFF); // the read command and the response received
        result = (result << 2) >> 2; // get rid of the last 2 bits, error(14) + parity(15)
        digitalWrite(11,HIGH); //Turn SS of

}

The code works perfectly with an UNO, but with M0, it event doesnt print the first SerialUSB.println("First Try");. The moment i erase the lines that have SPI commands in it, the serial monitor starts working again. As i said in the titel i am using the ICSP port on M0. I use the native usb port to programm.

I think i am missing something very basic. I checked many different forum posts, but there is no indication of M0 requiring other SPI commands. Any help is much appriciated.

PS: i didnt go into detail with the sensor and its datasheet because since it works fine with uno, the cause of the problem should be it.


texts: ESP32 Hardware Serial Flow control and full espressif/arduino-esp32 support

texts:
I have a similar issue. I want to use the ESP32 with RS485.
I have used the Arduino  and this works well assigning pins, but it seems not to allow full use of the UART.

I see the new uarts in the ESP32 can support the direction control (RTS) of the direction pin and there is actually a hardware RS485 mode.
See the repository that the board package is based on:
https://github.com/espressif/arduino-esp32

Then
https://github.com/espressif/arduino-esp32/tree/master/tools/sdk/include/driver/driver
uart.h

This shows we can actually have full hardware flow control, so no more guessing delays for controlling the DIR lines or getting interrupts when the send buffer is empty in order to know when to switch back to receive.

I found using board manager this did not all get installed, so I followed some tutorials on how to install it manually.
The board either doesn't appear at all, or I can't reference "uart.h".

Any ideas or examples?
Thanks,
Mark


texts: How do I import data from serial monitor to excel document without copying and pasting?

texts:
I need to be able to import incoming data from a motion sensor and then from the serial monitor (where the data is) import the data to an excel document or file.

Any suggestions would help,

Thanks.


texts: Error loading Blink sketch in esp01 (esp8266)

texts:
I have the esp01 connected the serial port using a usb to ttl serial cable and also using the Arduino UNO as suggested in some tutorials. I can execute AT commands. But loading a sketch from Arduino IDE results in error messages show below. If anyone can help, it would be greatly appreciated. Note the error message:

  serialport_receive_C0: F0 instead of C0

Build options changed, rebuilding all

Sketch uses 219,211 bytes (50%) of program storage space. Maximum is 434,160 bytes.     Global variables use 31,416 bytes (38%) of dynamic memory, leaving 50,504 bytes for local variables. Maximum is 81,920 bytes.
      /Users/syedtariq/Library/Arduino15/packages/esp8266/tools/esptool/0.4.8/esptool -vv -cd ck -cb 115200 -cp /dev/cu.usbmodem14221 -ca 0x00000 -cf /var/folders/hx/m49nxmvn0799w816ct3tgsjm0000gp/T/build10f6b721887f9efd16f05460daf22810.tmp/Blink.ino.bin
esptool v0.4.8 - (c) 2014 Ch. Klippel <ck@atelier-klippel.de>
setting board to ck
setting baudrate from 115200 to 115200
setting port from /dev/tty.usbserial to /dev/cu.usbmodem14221
setting address from 0x00000000 to 0x00000000
espcomm_upload_file
espcomm_upload_mem
opening port /dev/cu.usbmodem14221 at 115200
tcgetattr
tcsetattr
serial open
opening bootloader
resetting board
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: F0 instead of C0
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: F0 instead of C0
resetting board
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: FF instead of C0
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: F0 instead of C0
resetting board
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: F0 instead of C0
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
serialport_receive_C0: F0 instead of C0
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed


texts: Is this a good way to filter noise due to vibration in limit switch?

texts:
I have a circuit connected as follows

my limit switches which are attached to my structure sometimes gets falsely triggered, so I wrote this code to address it. My motor is supposed to go down skip the up limit switch at first hit the down one then go back to the up one. is this a good way to implement it?
https://pastebin.com/qVU1Gp0q

//Switch pressed ->  reading HIGH
//Switch not pressed -> reading LOW
//Motor direction 0 is down, 1 is up

const int uplimit = 32;
const int downlimit = 34;
const int motorspeed = 9;
const int motordirection = 28;
//const int pumpspeed=5;
//const int pumpdirection=6;
const int motorenable = 26;
//const int pumpenable=;
int Finishedcleaning = 0;
int Reachedup = 0;
int Motorinitialsetup = 0;
int Motorsecondsetup = 0;
int downfiltered = 0;
int upfiltered = 0;
void setup() {
  // put your setup code here, to run once:

  pinMode(motorspeed, OUTPUT);
  pinMode(motordirection, OUTPUT);
  pinMode(motorenable, OUTPUT);
  //pinMode(pumpspeed, OUTPUT);
  //pinMode(pumpenable, OUTPUT);
  pinMode(uplimit, INPUT);
  pinMode(downlimit, INPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  int average1 = 0;
  int average2 = 0;
  if (Motorinitialsetup == 0 ) // to be run before hitting initial switch
  { digitalWrite(motorenable, HIGH);
    analogWrite(motorspeed, 190);
    digitalWrite(motordirection, 0); // Bring motor down
    //   digitalWrite(pumpenable,HIGH);
    //  digitalWrite(pumpdirection,1);
    // analogWrite(pumpspeed,240);
    Motorinitialsetup = 1; //so this if statement does not run again

  }

  for (int i = 1; i < 100; i++)
  { downfiltered = digitalRead(downlimit);
    average1 = average1 + downfiltered;
  }
  average1 = average1 / 100;

  if ((average1 > 0.9) && Finishedcleaning == 0 ) // Function after hitting down switch
  {
    delay(1000); // wait until motor cross switch
    analogWrite(motorspeed, 0); // stop motor
    Finishedcleaning = 1; //indicate cleaning is over for next loop
    delay(500); // wait until motor cross switch
  }

  if ( (Finishedcleaning == 1) &&   (Reachedup == 0)  && (Motorsecondsetup == 0))
  {
    digitalWrite(motordirection, 1); // reverse motor direction
    analogWrite(motorspeed, 190); // start motor again
    Motorsecondsetup = 1;
  }

  if ( Motorsecondsetup == 1) // only checks switch up switch after motors comes back
  {

    for (int i = 1; i < 300; i++)
    { upfiltered = digitalRead(downlimit);
      average2 = average2 + downfiltered;

    }
    average2 = average2 / 300;
    if ((average2 > 0.9) && (Finishedcleaning == 1)) // Stop Motor after returning
    { analogWrite(motorspeed, 0);
      delay(1000);
      Reachedup = 1; // indicate finished returning after cleaning cycle
    }
  }
}


texts:
I created a quite simple Arduino sketch:

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

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

  float voltage = sensorValue * (5 / 1023.0);
  Serial.println(voltage);

  delay(1000);
}

I use the following circuit:

My multimeter measures 3.31 V, between the pin 3V3 and GND.

I get a sensorValue of 730 and a calculated voltage of 3.57 V. This is 8% higher that 3.3V. What is the tolerance by the AD-converter?


texts: arduino resets or hangs after providing power to DHT22

texts:
I'm developing a low power project based on Atmega328p which among other things uses a DHT22 to measure air humidity. DHT22 spec says that it consumes 50uA when idle. This is too high for me (I'm aiming at sub 10uA consumption for the whole device when in sleep mode) so I've figured out that I'll just power it from one of Atmega328p pins. This will give me the ability to turn it off or on at software level. DHT22 consumes only 1.5mA during measurement so I should be fine (a single Atmega's pin can safely provide up to 20mA). I've set up a following test circuit:

The red wire powers DHT22, the blue one is for data transfer, the black one is GND and the 4.7k is a pull-up resistor.

My problem is that after I turn on the DHT22 using just:

digitalWrite(4, HIGH);

the Atmega either resets or hangs or... successfully turns on the DHT22 and keeps working, but that happens about 10% of the time. My suspicion is that there is some current spike in the moment of supplying power to the DHT22. Unfortunately I don't have an oscilloscope to confirm this.

I've added a 220 ohm resistor between VCC pin of DHT22 and the pin 4 on the Arduino and it solved the problem. My question is: will it work like this reliably? Are humidity readings reliable when voltage is not stabilized (but stays within 3.3-5.5V range as required by the datasheet)? I could of course use a transistor to turn it on/off, but I'd like to keep it as simple as possible.

Why DHT22's datasheet doesn't mention this current spike? Here it is for reference: http://www.adafruit.com/datasheets/Digital%20humidity%20and%20temperature%20sensor%20AM2302.pdf


texts: Battery voltage monitor right after deep sleep

texts:
i have my esp32 module in deep sleep and i use it with a couple of buttons using a wake up that detect the button pressed
now i'd like to have a battery level to send to a server right before going back to deep sleep. How can i do it?
and what cheap rgb led do you suggest using?


texts: Arduino Mega PWM pins stop working for LEDs once servo is attached?

texts:
I can get LEDs to fade properly using PWM on pins 44-46 on the Mega2560 when I don't have a servo attached, but once I "attach" the servo in the code, then PWM pins 44-46 don't work for PWM. They can still work with digitalWrite, but not with analogWrite.

This is the code:

#include <Servo.h>
Servo myservo;
int led = 46;

void setup()  {
  myservo.attach(3);
  pinMode(led, OUTPUT);
  analogWrite(led, 60);
}

void loop()  {}

If I comment out the "myservo.attach(3);" line, then PWM works for the LED pin. Otherwise the LED stays off. Why would PWM on pins 44-46 stop working once the servo is attached?


texts: How can I make a data logging multimeter?(harvesting energy from human motion)

texts: I’m an industrial design major working on a studio project that involves electronics that are kind of out of my league. I have a few low power generators like piezos, thermoelectric (peltier) tiles etc... In order to progress with my project I need a way to measure the output of each one individually when harvesting human motion. As far as I know, I need a multimeter to hook up directly to these devices, and then I think there may be a way to record the results with an arduino. My question is more about specifically how to do this, or even if this is a feasible plan. Are there any plans for this sort of thing already out there? Any feedback will be greatly appreciated!


texts:
I just managed to get a unofficial Arduino WiFi shield to work. But the ESP is flashed on its own now - providing only information to the USB->TTL converter and therefore the output goes straight to the Serial Monitor of the Arduino IDE.

Since the ESP is flashed and should be running now - I should be able to disconnected the USB->TTL converter and attach the Arduino RX/TX to the ESP TX/RX right?

Then I should receive Serial Data and should be able to process these in my Arduino Sketch right?

So what do I need to do now? Should I start trying a Serial read from the arduino with the baud rate specified by the ESP Flash (11520)? Or do I have to consider something else as well?


texts: I was instructed to "burn the bootloader" to my Arduino to fix an error I was getting. How can I do this? (And what exactly is the bootloader?)


texts: Esp8266 esp01 kicks other devices off tplink router

texts:
I had an Esp8266 esp01 module programmed to log onto the router and post data.  It worked fine for a few months but all of a sudden it kicks everyone else off the router.

Actually as soon as I connect the Esp and it connects to the ssid, it kicks off my laptop (laptop can no longer even see the ssid) and I see my Google home drop it's connection as well.  It's almost immediate, about 20 seconds after powering up my esp.  Seconds after I unplug the Esp google home comes back on and my laptop sees the ssid again.

What should I check for in my router?  It's a tplink tr-wl945N.


texts: How can program/arduino restarted by IDE?

texts:
I wrote my custom sketch, where I am printing some greeting text inside setup() method.

I found, that each time I am restarting IDE, and opening serial monitor, a greeting text is printed there again, i.e. setup() method running again.

How can this happen? I was thinking setup() method run once, when Arduino is powered up by connecting to the USB socket?

If it is possible to restart it already connected, then how this can be done?

UPDATE

Code is follows:

#include <Wire.h>
#include <Adafruit_BMP085.h>

Adafruit_BMP085 bmp;

String command;

String awaitingMessage = "Temperature and pressure sensor awaiting commands\r\nCommand \'help\' is for help";

void awaiting() {
  Serial.println(awaitingMessage);
}

void help() {
  Serial.println("Temperature and pressure sensor commands:");
  Serial.println("temp\t- output temperature in degrees Celsius");
  Serial.println("press\t- output pressure in Pascals");
  Serial.println("wait\t- print awaiting message");
  Serial.println("help\t- output this text");
}

void temperature() {
  Serial.println(bmp.readTemperature());
}

void pressure() {
  Serial.println(bmp.readPressure());
}

void unknown() {
  if( command.length() > 0 ) {
      Serial.println("Unknown command was \'" + command + "'");
    }
}

void setup() {
   Serial.setTimeout(50000);
  Serial.begin(9600);
  if (!bmp.begin()) {
    Serial.println("Could not find a valid BMP085 sensor, check wiring!");
    while (1) {}
  }
  else {
    awaiting();
  }
}

void loop() {
  command = Serial.readStringUntil('\n');

  if( command.startsWith("temp") ) {
    temperature();
  }

  else if( command.startsWith("press") ) {
    pressure();
  }

  else if( command.startsWith("wait") ) {
    awaiting();
  }

  else if( command.startsWith("help") ) {
    help();
  }

  else {
    unknown();
    //awaiting();
  }

}

Video is here: https://youtu.be/-QBleGVxaus


texts:
Im soldering an LCD screen to my Arduino as I don't have a breadboard and plan on it being permanent. I'm wondering how I should connect the potentiometer (to control contrast).

If I connect it as the first component in series, will this affect the main power to the LCD?

Should I use both 5v pins on the Arduino instead? (Mine has two anyway, I dont know if the official one does).

Would splitting a cable work?

Im new to electronics so sorry if the questions are stupid.

I intend to use the circuit from: https://www.arduino.cc/en/Tutorial/HelloWorld.
Thanks for any help.


texts: How can I compile my code via terminal? I am working on a Chrome app that allows you to write, compile, and upload code to an Arduino, and I need to know this so I can use the command line compiler on my Linux server. Mac or Linux terminal, it doesn't matter.


texts:
I need to print an unsigned long long variable:

unsigned long long t = 1559072327000ULL;

I have tried the following:

Serial.println(t); // call of overloaded 'println(uint64_t&)' is ambiguous

char[18] buf;

sprintf(dt, 18, "%lu", t); // Prints 4294165848

snprintf(dt, 18, "%lu", t); // Prints 126

vsnprintf(dt, 18, "%lu", t); // cannot convert 'uint64_t {aka long long unsigned int}' to '__gnuc_va_list {aka __va_list_tag}'

Any suggestion?


texts: ESP32 Low Power Reconnect Latency Question

texts:
I am trying to develop a small 9-button BLE keyboard on the ESP32 with a rotary encoder as a volume knob. My question involves the low power modes and the time it takes for them to wake up.

My system enters sleep mode after 5 seconds of inactivity from the user.
The issue is when the ESP wakes up from light sleep - it takes around 1 to 2 seconds for bluetooth to reconnect, and the keystroke or action that woke it up isn't processed.

How can I address the issue of a faster reconnect? I want the system to save power when it is not in use, but I also wish for it to be responsive when coming out of this low-power state to process user requests.

Here is the processing block:

while (true) {
    //Begin sleep if user has not interacted for >= 5 seconds
    current_sys_time = millis();
    if (current_sys_time - last_sys_event_time > MAX_ALLOWED_IDLE_TIME)
        light_sleep_begin();

    //Play/pause media when rotary encoder switch is pressed
    if (digitalRead(PIN_SW) == LOW && play_pause_btn == NOT_PRESSED) {
        delay(25);
        if (digitalRead(PIN_SW) == LOW)
            play_pause_btn = WAS_PRESSED;
        last_sys_event_time = millis();
    }
    else if (digitalRead(PIN_SW) == HIGH && play_pause_btn == WAS_PRESSED) {
        last_sys_event_time = millis();
        play_pause_btn = NOT_PRESSED;
        bleKeyboard.write(KEY_MEDIA_PLAY_PAUSE);
    }

    //Turn volume up or down when encoder is turned clockwise or ocunter-clockwise, respectively
    if (encoder_read()) {
        if (encoder_4bit_sample == CLOCKWISE)
            bleKeyboard.write(KEY_MEDIA_VOLUME_UP);
        else if (encoder_4bit_sample == COUNTER_CLOCKWISE)
            bleKeyboard.write(KEY_MEDIA_VOLUME_DOWN);
    }
}

And here is my sleep function:

void light_sleep_begin()
{
    gpio_wakeup_enable(GPIO_NUM_33, GPIO_INTR_LOW_LEVEL); //Encoder SW pin
    gpio_wakeup_enable(GPIO_NUM_35, GPIO_INTR_LOW_LEVEL); //Encoder CLK pin
    gpio_wakeup_enable(GPIO_NUM_32, GPIO_INTR_LOW_LEVEL); //Encoder DT pin
    esp_sleep_enable_gpio_wakeup();

    esp_light_sleep_start();
}

Board: ESP32 DevkitC \
IDE: PlatformIO \
Module: ESP32 WROOM


texts: Buy a genuine arduino board or a sainsmart board?

texts: Arduino Day is so popular! Many boards are cheap during arduino day. So should I buy a genuine arduino board or a sainsmart board?


texts:
I just bought an Arduino Mega2560 R3 and it doesn't connect to my Laptop. The connection is somewhat random, sometimes it connects and sometimes it doesn't.

Can someone help me identify whats the problem?

When it gets connected I can upload sketches.

I would like to remove the Atmega 16U2 and replace it with ftdi USB to Serial, would it be possible?


texts: How to define SoftwareSerial pins on ESP8266

texts:
I'am new to arduino yun and ESP. In fact, i have an arduino yun which has a sim808 dfrobot shield on it which uploads GPS data online at a regular time interval.

I want to connect the dfrobot sim808 shield to esp so that the latter will send the data online thus making the system low cost by not using the arduino yun

#include  <DFRobot_sim808.h>
#include  <SoftwareSerial.h>
#include  <Console.h>

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

I want to know which pin on the sim808's TX and RX pin should be connected to the ESP8266 like define above, pin 0,1 are used by the yun for Wifi connectin so pin 10 and 11 are used. . By the way, I am currently using ESP8266 12E nodemcu. Please help me with that.


texts: Three or more Arduino slaves sending bytes to 2 different I2C devices

texts:
I'm trying to connect 3 Arduinos with this scheme: Arduino1 Master, Arduino2 Slave, Arduino3 Slave. The slave devices need to communicate with each other and I'm trying to programming Arduino2 and transmit bytes to the other slave device Arduino3 and Master Arduino1 at the same time. Is that possible?

Master CODE:

#include <Wire.h>

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

void loop() {
  Wire.requestFrom(0x04, 2);
  while (Wire.available()) {
    var1 = Wire.read();
    var2 = Wire.read();
  }
}

Arduino1 Slave:

#include <Wire.h>

void setup() {
  Wire.begin(0x05);
  Wire.onReceive(receiveEvent);
}

void loop() {
}

void receiveEvent(int howMany) {
  var1 = Wire.read();
  Serial.print("VAR1 is : ");
  Serial.println(var1);
}

Adrduino2 Slave code:(Where I think I'm wrong)

#include <Wire.h>
int var = 123;
int var2 = 123;
int var3 = 123;

void setup() {
  Wire.begin(0x04);
  Wire.onRequest(requestEvent);
}

void loop() {
  Wire.beginTransmission(0x05);
  Wire.write(var);
  Wire.endTransmission();
}

void requestEvent() {
  Wire.write(var1);
  Wire.write(var2);
}

Is this the correct way to make the Arduino2 send to 2 devices?


texts: Increasing distance of IR remote / transmitter

texts:
I am trying to set up my Arduino as a replacement remote control. The setup works and I can use it to turn on/off my things, for example my fan.

However, the working distance is quite short. Around a meter. The actual remote for my fan works across the distance of my apartment.

What can I do to improve the working distance of my Arduino remote? Does the LED need a back reflector or something? Does it need a different LED?

The LED I am using is this, it came in a bundle I purchased.
https://www.amazon.com/dp/B07PJC7WSQ/#detail-bullets


texts: SMD Voltage Regulator 662k very hot, how to repair it?

texts:
I think I made a mistake. Now, the 662k on my Arduino Uno very hot about 90°C.

I test it, it can be programmed and can run blink program normally.

There is a switch for voltage choose. Now, run in 3.3v mode get 2.8v and in 5v mode get 4.8v.

What should I do?

If 662k be replaced, can I use that Arduino normally in the future.


texts:
I'm confused with what I'm reading.

I have Serial communicating with my PC (USB) and SoftwareSerial over RS485 to a remote PC. I don't want to duplicate all of my print statements to be able to send output to either (or both) terminals. What I want to do is have a single set of print statements (think of a list of error messages) and then be able to output a message to either Serial or SSerial depending on which needs it. Does this make sense?


texts: Arduino Uno and Raspberry Pi USB Serial Communication

texts:
I am trying to get Arduino Uno with Raspberry Pi to communicate with each other. I want the python script to write a message and for my Arduino to read it. This was working before, but I came back a week later and it stopped. Essentially, I want the Raspberry Pi to write '3' and for my Arduino to recognize this 3 and light up some LEDs. Where do you think I am going wrong? The Arduino works when testing it through the IDE and Serial Monitor. There are no errors when running the python script, the LEDS just don't light up, so I assume there is some miscommunication.

Python Code

import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
ser.write('3')

Arduino Code

String serialRead;
int val;
void setup() {
  Serial.begin(9600);
  strip.begin();
  strip.setBrightness(25);
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  serialRead = Serial.read();
  if (Serial.available() > 0) {
    val = Serial.read();

    if (val > '0' && val <= '9') {
      Serial.println(val);
      val = val - '0';
      Serial.println(val);

      if (val == 3)
      {
        //strip.setBrightness(100);
        colorWipe(strip.Color(127, 127, 127), 50);
        colorWipe(strip.Color(0, 0, 0), 50);
      }
    }
  }
}


texts: Is it possible to disable functions/methods?

texts:
I recently started using the TimeAction library (which allows for proto-threading) and I noticed it has a really useful function for enabling/disabling threads. I want to use the same idea but apply it to a general function, though I haven't been able to find a possible solution to doing such a task on the internet. Here is a potential way for how I would like to implement it:

#include <TimedAction.h>

boolean disableCheck = false;
boolean checking = false;
boolean state = false;
const int motionPin = 5;
void checkMotion();
void motion();
void DisableCheckMotion();

TimedAction checkable = TimedAction(6000, DisableCheckMotion);

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

void loop() {
  checkMotion(); //this will be the function I wish to enable and disable

  if(checking == true)
  {
    motion();
  }
  if(disableCheck == true)
  {
    checkable.check();
  }

}
void checkMotion()
{
   checking = true;
}
void motion()
{
   if(digitalRead(motionPin) == HIGH)
{
   Serial.println("motion");
   checking = false;
   checkable.check();
}
}
void DisableCheckMotion()
{
  state ? state = true : state = false;
  if(state == false)
{
  checkMotion.disable(); //this is where I would like to disable the function
  disableCheck = true;
}

  if(state == true)
{
  checkMotion.enable(); //this is where I would like to enable the function
  disableCheck = false;
}
}

The purpose of this task is to output one value for whenever a PIR scanner (set at pin 5) picks up motion. Without any form of delaying it will flood the output with values (which is undesirable). A thread is used to offer this delay, I cannot put the code for checking for motion within the thread as I could risk the chance of a reading being missed.

The ideal setup would be for the Arduino board to receive the input and then delay the input from being received again for a period of time while not delaying the entire program. What would be the best way to implement this?


texts:
I'm using the Teensy 2.0 (atmega32u4) and decided to switch from Arduino IDE with Wiring to pure C. I think it's much more useful to master programming microcontrollers on that level. Wiring seems to be quite limited at some point.

It was really easy to use some basic libraries such as avr/io, or util/delay and write simple programs like "arduino hello world".

My problem comes with more complex tasks such as acting as usb mouse. On http://pjrc.com are references just to use with arduino ide/wiring. I couldn't find anything useful on google. Is there any good reference for pure C programming tennsy/arduino and/or using libraries such as "usb_mouse.h" (from pjrc.com) with pure C?

EDIT 1

Let me add some details (based of @st2000 answer).. Yes, Tennsy (and Arduino) are microcontrollers, not microprocessors. Programming avr chips in pure C doesn't require so much work as programming microprocessors. This is the simplest avr C program I could come with (typical blinky):

#include <avr/io.h>
#include <util/delay.h>

int main(void) {
        (CLKPR = 0x80, CLKPR = 0x00);
        DDRD |= (1<<6);
        PORTD &= ~(1<<6);

        int sviti = 0;

        while (1) {
                if (sviti)
                        PORTD |= (1<<6);
                else
                        PORTD &= ~(1<<6);
                sviti ^= 1;
                _delay_ms(40000);
        }
}

As you can see (@st2000), there are no dozens of setting up registers. It does not require any expensive equipment to upload resultant .HEX file - for teensy the only thing you need is a USB cable.

If you want a concrete example, I want to use this library with pure C, but it's obviously meant for wiring and arduino IDE primary. So how to use this library with pure C? And back to my main question, how to generally use libraries of this kind with pure C avr programming?


texts:
Curently I am using these connectors for my prototype:
Ebay link

However, I need something more reliable so I can deliver the prototype to a user without to risk that the cables fall out of their pins.
Is there something else to use? I would like to avoid soldering.. :(


texts: What is the proper wiring for relay module?

texts:
I want to know the recommended wiring for relay. I am setting it up as NO.

Where should I connect the relay, the hot wire or the ground wire?
Where should I connect the wire going to bulb, NO or C pins of relay? Where should I connect the wire going to AC, NO or C?


texts:
Is it possible to get GPS data without using a GPS, but instead using the internet provided from a 3G or 4G connection to get GPS data?

Maybe if you used the HTML5 geolocation API somehow?

I have already used a GPS module together with a GSM modem, but i only used the GSM modem for SMS and not potential internet capabilities.

The beneftis from this , besides cost, would be a smaller program, intended for arduino nano, as TInyGPS and TinyGPS++ libraries are already big enough.

So my question really is twofold:
1. Is there any way to utilize the internet connection from GSM modems (besides the obvious SMS/call function)?
2. Is there a way to utilize the internet connection to get GPS data, without using an actual GPS module?


texts:
I made a little joystick input recorder that stores the joystick state (8 directions + fire) and the time (how long was a button or direction pressed).

Example data would be like this (i = input, t = time in milliseconds):

i: 0 | t: 2003
i: 2 | t: 128
i: 0 | t: 28
i: 10 | t: 27
i: 2 | t: 36
i: 18 | t: 39

My problem is that I run out of memory on an Arduino Uno very quickly. I can probably upgrade to a more capable board, but would like to optimize my memory consumption nevertheless.

 const byte max_record = 200;
 byte sequence[max_record];
 int time[max_record];

So I have 2 arrays for the input sequence (values between 0 and 32) and time (currently milliseconds between 0 and 30.000 or even higher).

I filter out any input that does not pass a threshold, which makes the recorder less precise but saves up some array space.

Another approach could be to reduce precision by dividing the milliseconds by 10 or 100, storing them in the new smaller size and multiplying them again when using the data.

Any other advice is greatly appreciated.


texts:
I am trying to use Arduino as Modbus- RTU slave and Raspberry Pi as a Modbus master I have interfaced Max485 (RS485 to TTL converter) with Arduino and Rs485 to USB converter in Raspberry Pi, Initially, I was able to send data from Arduino to Raspberry Pi, but the data seems to inconsistent and fails to read most times

I am using https://github.com/smarmengol/Modbus-Master-Slave-for-Arduino for Arduino Minimal Modbus for raspberry pi

Connections:

DI(max485)- TX ( Arduino),
DE(max485) -D2 ( Arduino),
RE(max485) - D2( Arduino),
Ro(max485) - RX( Arduino),
Vcc(max485) -5v( Arduino),
Gnd (max485)- GND( Arduino)

code for Arduino

#include <ModbusRtu.h>
uint16_t au16data[6] = {};
Modbus slave(5,0,2);
void setup() {
  slave.begin(19200,SERIAL_8N2 );
 }
void loop() {
  au16data[0]=100;
  au16data[1]=200;
  au16data[2]=300;
  au16data[3]=400;
  au16data[4]=500;
  au16data[5]=600;
  slave.poll( au16data, 6 );
  delay(3000);
}

python code

import minimalmodbus
from datetime import datetime
import time

instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 5)
instrument.serial.baudrate = 19200
instrument.serial.bytesize = 8
instrument.serial.parity = minimalmodbus.serial.PARITY_NONE
instrument.serial.stopbits = 2
instrument.serial.timeout =6
instrument.mode = minimalmodbus.MODE_RTU

while(1):
    try:
        val = instrument.read_registers(0,6)
        # Registernumber, number of decimals
        print val
    except IOError:
        error_msg = "Failed to read from device"
        error_time = datetime.now()
        print "IO Error Time",error_time.isoformat(),error_msg

    except ValueError:
        error_msg = "Failed to read CRC"
        error_time = datetime.now()
        print "Value Error Time",error_time.isoformat(),error_msg
    time.sleep(2)

but now I am getting The exception of failed to read


texts: Trying to do hello world app for Nokia 5110 LCD with arduino yun and johnny five

texts:
I have a Nokia 5110 LCD which is using this display PCD8544, I am using a arduino yun and johnny five I have hooked up the following pins. So far with my node app all that happens is the lcd lights up. I am not sure if maybe the lcd is not supported with johnny five, if I have a pin wrong. I followed this site for the pin setup https://lastminuteengineers.com/nokia-5110-lcd-arduino-tutorial/ Any help would be greatly appreciated. This is my first attempt with Johnny five and second attempt at hooking anything up to a bread board. Hope we can get this working. Thanks

Here is my code

const five = require('johnny-five');
const board = new five.Board();

board.on("ready", function() {

    lcd = new five.LCD({
      controller: "PCF8574"
    });

    lcd.print("Hello");
  });

Here is my configuration

blue         =  pin 7          sclk     (serial clock(CLK)) 10 om
white        =  pin 6          DN(MOSI) (Serial data in) 10om
grey         =  pin 5          D/C      (Mode select) 10om
orange       =  pin 4          RST      (Reset) 10om
yellow/red   =  pin 3          SCE      (Chip select) 10om
yellow-short =  power strip +  LED      (backlight supply) 1kom
green/black  =  gnd / strip -
blue/power   =  3.4v power + 330om

Here is are some images of the setup

Update so my configuration looks more like this now

blue         =  pin 7          sclk     (serial clock(CLK)) 10k
white        =  pin 6          DN(MOSI) (Serial data in) 10k
grey         =  pin 5          D/C      (Mode select) 10k
orange       =  pin 4          RST      (Reset) 10k
yellow/red   =  pin 3          SCE      (Chip select) direct
yellow-short =  power strip +  LED      (backlight supply) 330
green/black  =  gnd / strip -
blue/power   =  3.4v power powerstrip direct


texts: Read gyro output values with other programming languages

texts: I have a large quantity of gyro values and I read them through the Arduino serial monitor. I'd like to know how I can use these values in other programming languages (such as C/C++/Java) after the values are read. Are there particular  libraries for the Arduino that could help me in this way?


texts: Trying to power 100 Arduino's from single power line

texts:
I'm trying to power up to 100 Arduinos that will be spread across a 25m wall using a single power line.

The idea is each Arduino will have a few a few buttons, leds & an oled screen and will all communicate to a master server using rs485.

====[A0]====[A1]====[A2]====[A3]====[A4]== ... ==[A99]

I've already followed this brilliant post http://www.gammon.com.au/forum/?id=11428 to implement the data connection using an rs485 bus.

However I'm struggling to understand how I could power multiple Arduino's from the one line and not introduce surges/ground loops from the difference in group potential caused by the long power line.

Would I have to isolate each Arduino and rs485 driver? Or is there a simpler solution?


texts: Sending struct from Arduino to Raspberry Pi - wrong types

texts:
I'm using Raspberry Pi and Arduinos for my home automation project where Raspberry Pi is the controler of Arduino nodes.
I use nRF24 wireless transceivers to communicate.

My problem is that when I was sending a structure like following

struct TempSensorData

{
      uint32_t result;
      uint32_t temperature;
      uint32_t humidity;
    };

From Raspberry to Raspberry everything went fine but now when I use Arduino as sender I get very strange results:

received: status: 335544320, temperature: 754974720 degrees, humidity: 0%

While on Raspberry it was

received: status: 0, temperature: 22 degrees, humidity: 44%

Can this be a problem with types? Or with different type of architecture (like different sizes on 3-2bit and 64-bit arch)?

EDIT:

Code on Raspberry:

if (radio.available())

{
        // dump the payloads until we've got everything
        Message receivedData = {0};
        radio.read(&receivedData, sizeof(Message));
        TempSensorData data = receivedData.msgData.tempSensorData;
        std::cout << "received: status: " << data.result << ", temperature: " << data.temperature << " degrees, humidity: " << data.humidity << "%" << std::endl; //TODO here we have some strange numbers - check if we have proper types
    }

Before that I have:

radio.begin();
radio.setPALevel(RF24_PA_LOW);
radio.setChannel(0x4c);
radio.openReadingPipe(1, RASPI_READ_ADDR);
radio.openWritingPipe(RASPI_WRITE_ADDR);

radio.enableDynamicPayloads();
radio.setAutoAck(true);
radio.powerUp();
radio.startListening();

And on Arduino:

Header header = {thisNodeId, thisNodeType, 0, static_cast<uint8_t>(MsgType::TEMP_SENSOR_DATA), 12345, Status::ok};
TempSensorData dhtData;
dhtData.result = DHT.read11(DHT11_PIN);
dhtData.humidity = (int)DHT.humidity;
dhtData.temperature = (int)DHT.temperature;
Message message = {0};
message.header = header;
message.msgData.tempSensorData = (dhtData);
radio.stopListening();
radio.write(&message, sizeof(message));
radio.startListening();

I also use a common header with defined structures for both Arduino and Raspberry, which contains:

#define RASPI_WRITE_ADDR 0xF0F0F0F0F0LL
#define RASPI_READ_ADDR 0xF0F0F0F0E1LL

struct TempSensorData {
  uint32_t result;
  uint32_t temperature;
  uint32_t humidity;
};

enum class Status : uint8_t

{
        ok,
        error,
        fail
    };

enum class MsgType : uint8_t {
    INITIALIZATION,
    RESET_REQUEST,
    ACK_NACK,
    TEMP_SENSOR_DATA,
};

struct Header {
  uint8_t nodeId;
  uint8_t nodeType;
  uint8_t location;
  uint8_t msgType;
  uint16_t checksum;
  Status status;
};

union MsgData {
  InitMsgData initMsgData;
  AckNack ackNack;
  TempSensorData tempSensorData;
};

struct Message {
    Header header;
    MsgData msgData;
};

radio is an item of RF24 class from https://github.com/TMRh20/RF24/

Unfortunately the RF24 repo is 64 commits ahead of what I use.

EDIT2:

Maybe the problem lays in that

enum class Status {};

which I use in both files.

I must add that I use g++-4.7 when compiling on Raspberry and when compiling on Arduino I use avr-g++-4.8.2


texts: Is it possible to run the Teensy to the Arduino?

texts:
I'm already done copying/pasting the libraries that I know is needed to run the program, but I wonder why I always get this error every time I tried to run the code. What do you think would be the possible reason why I get this error:

  C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:64:14: warning:
  #warning Using current Arduino IDE with Wire library is functionally
  limiting.   [-Wcpp]

  #warning Using current Arduino IDE with Wire library is functionally limiting.

          ^

  C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:65:14: warning:
  #warning Arduino IDE v1.0.1+ with I2CDEV_BUILTIN_FASTWIRE implementation
  is recommended. [-Wcpp]

  #warning Arduino IDE v1.0.1+ with I2CDEV_BUILTIN_FASTWIRE implementation
  is recommended.

          ^

 C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:66:14: warning:
 #warning This I2Cdev implementation does not support: [-Wcpp]

 #warning This I2Cdev implementation does not support:

          ^

 C:\Program Files (x86)\Arduino\libraries\I2Cdev\I2Cdev.cpp:67:14: warning:
 #warning - Timeout detection (some Wire requests block forever) [-Wcpp]

 #warning - Timeout detection (some Wire requests block forever)

          ^

 In file included from C:\Program Files
 (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp:27:0:

 C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp: In member
 function 'bool RTIMUHal::HALRead(unsigned char, unsigned char, unsigned
 char, unsigned char*, const char*)':

 C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.h:59:37: error:
'class HardwareSerial' has no member named 'printf'

 #define HAL_ERROR1(m, x)     Serial.printf(m, x);

                                 ^

C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp:73:13: note:
in expansion of macro 'HAL_ERROR1'

         HAL_ERROR1("I2C read failed - %s\n", errorMsg);

         ^

  C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp: In member
  function 'bool RTIMUHal::HALWrite(unsigned char, unsigned char, unsigned
  char, const unsigned char*, const char*)':

  C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.h:59:37: error:
  'class HardwareSerial' has no member named 'printf'

  #define HAL_ERROR1(m, x)     Serial.printf(m, x);

                                 ^

  C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp:96:13:
  note: in expansion of macro 'HAL_ERROR1'

         HAL_ERROR1("I2C write failed - %s\n", errorMsg);

         ^

   C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp: In member
   function 'bool RTIMUHal::HALWrite(unsigned char, unsigned char, unsigned
   char, const char*)':

   C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.h:59:37:
   error: 'class HardwareSerial' has no member named 'printf'

   #define HAL_ERROR1(m, x)     Serial.printf(m, x);

                                 ^

  C:\Program Files (x86)\Arduino\libraries\RTIMULib\RTIMUHal.cpp:119:13:
  note: in expansion of macro 'HAL_ERROR1'

         HAL_ERROR1("I2C write failed - %s\n", errorMsg);

         ^

  exit status 1
  Error compiling.


texts: Problem with LCD keypad shield and Arduino Uno R3

texts:
I have a problem with powering my LCD Keypad Shield from a DC cable (4 AA batteries or 9V battery). Everything looks good, but the LCD screen doesn't display anything. When I used a USB cable, the screen works as it should.

What is the problem?


texts: Flickering LCD backlight with fingerprint scanner

texts:
I have the following problem: for some *** reason, my LCD is flashing when my fingerprint scanner turns on. Here is a video of the behavior: https://www.dropbox.com/s/mqk4u0vu8yvhiwz/IMG_3171.m4v?dl=0.

More details: I have a membrane keypad. When I start typing on it, the LCD turns on, and when I type the correct code, the fingerprint scanner turns on, and the LCD prompts the user to press a finger upon the scanner. However, then the LCD backlight starts flashing badly. Interestingly, if I just plug the wall adapter into the arduino and try the scenario, the LCD does not flash. However, if let's say 10-15 have passed since the adapter is plugged in, the LCD flickering becomes visible and irritating (again, when the fingerprint scanner is turned on). So, what could be the reason and how to fix it? Why if I just plug the adapter and execute the scenario, the LCD does not flash, and if I wait some time with the adapter plugged in, and then execute the scenario, the LCD flickers?

Just to add: My fingerprint scanner is GT511C1R (https://www.sparkfun.com/products/13007) and I am using the standard scheme for wiring it (560/1000 ohm for the RX). I am not using lcd.clear() command as I know it's heavy, and even if I don't write any text, the still LCD flickers.

Best regards,
Nike


texts: detecting signal coming from another motion sensor that triggers camera's shutter

texts: I have a motion sensor (used for camera trapping) that sends a signal to the camera to trigger the shutter. I am trying to use Arduino to turn on lights for 10 seconds by getting the signal from the motion sensor. I know there are ways to use motion sensor that can be used with Arduino. However, I need to know how I can detect a signal coming from the sensor to feed it to Arduino. I have tried connecting the cable from the sensor to A0, wrote a simple code to print the value of A0 but the serial monitor of Arduino shows nothing.


texts:
I have a problem with the shift register 74HC595.

The sketch I use is able to enable a specific led (8 are connected).

When I enable led 0 to 7 it behaves like normally (they switch on when I enter the numbers).

However, for the led connected to pin 15 (other side of the ic, see layout) it behaves differently.
 When I switch this led on, ALL leds go off. When I retry, nothing happens. When I enable another led, after a short time (but can be seconds) the led for pin 15 is emitting light together with all others which where already enabled.

This seems like a malfunction in the IC (I checked already another led, another cable, another resistor). The only think I haven't checked is moving the IC to another position of the breadboard (that would take a lot of time since I have to rewrite everything). Is it possible I missed something or is the shift register broken?

The code to switch on a led:

void updateShiftRegister()
{
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, LSBFIRST, leds);
  digitalWrite(latchPin, HIGH);
}

where leds are the indices of the leds (0..7).


texts:
Did someone ever used the Infineon Optiga Trust X module with Arduino using any I2C library ?

Here is the technical documentation of the Trust X module.

I'm trying to get the I2C_STATE register data but I don't receive anything after the Wire.requestFrom().

I also tried with the DSS Circuits I2C Master Library, same results.

Thanks

Full code :

#include <Wire.h>
#define PIN_RST 8
#define PIN_VDD 9

void setup() {
  pinMode(PIN_RST, OUTPUT);
  pinMode(PIN_VDD, OUTPUT);
  digitalWrite(PIN_RST,LOW);
  digitalWrite(PIN_VDD,LOW);

  Serial.begin(115200);
  delay(2000);
  Wire.begin(); // join i2c bus (address optional for master)

  digitalWrite(PIN_VDD,HIGH);  // sartup the Trust X module
  digitalWrite(PIN_RST,HIGH);

  delay(15);  // startup min delay
}

long val = 9999;

void loop() {
  Wire.beginTransmission(48); // transmit to device #48 (0x30)
  Wire.write(byte(0x82));            // sends instruction byte
  Wire.endTransmission();     // stop transmitting

  Wire.requestFrom(48, 4);
  while(Wire.available()==0){}

  val = Wire.read(); // Reads the data from the register
  Serial.print("val = ");
  Serial.println(val);

  delay(5000);

}


texts: PIR sensor and sleep (interrupt) on Mega2560

texts:
So I was starting to gain some knowledge on the PIR sensor and how to let the Arduino 'sleep' while there is no movement detected by the PIR.

I found the following code somewhere and looked fairly simple. So  I thought I would give it a try and grabbed my Mega2560, a LED and a PIR sensor.

While it was seeming to work at first sight, the Arduino is doing the opposite from what I was expecting. It turns off the LED and the Arduino when there is movement, instead of turning off the Arduino when there is NO movement. As I said before, it is doing pretty much the inverse.

Probably an easy solution, but can't figure it out on my own.

The code:

#include <avr/sleep.h>

int wakePin = 2;                 // pin used for waking up
int led = 13;

void wakeUpNow() {
}

void setup() {
  pinMode(wakePin, INPUT_PULLUP);
  pinMode(led, OUTPUT);
  attachInterrupt(0, wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function wakeUpNow when pin 2 gets LOW
}

void sleepNow() {
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
    sleep_enable();          // enables the sleep bit in the mcucr register
    attachInterrupt(0,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
    digitalWrite(led,LOW);
    sleep_mode();            // here the device is actually put to sleep!!
    // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
    sleep_disable();         // first thing after waking from sleep: disable sleep...
    detachInterrupt(0);      // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time.
    digitalWrite(led,HIGH);
}

void loop() {
  sleepNow();     // sleep function called here
}

Thanks in advance.

EDIT

Adapted the code to the following and seems to work now. When motion is detected by the PIR it turns on the LED on pin 13; when no motion is detected, the LED is turned off.

Two questions still remain:

1) How can I be sure that the Arduino really sleeps now?

2) When the Arduino just entered sleep, it takes a couple of seconds (+/- 6s) before it can pick up another motion. Can I get a faster detection or another 'sleep' or 'powersave' method that lets the Arduino react faster to motion?

#include <avr/sleep.h>

const int wakePin = 2;                 // pin used for waking up
const int led = 13;

int wakeVal = 0;
int wakeState = LOW;

void wakeUpNow() {

}

void setup() {
  Serial.begin(9600);
  pinMode(wakePin, INPUT_PULLUP);
  pinMode(led, OUTPUT);
  //attachInterrupt(0, sleepNow, LOW); // use interrupt 0 (pin 2) and run function wakeUpNow when pin 2 gets LOW
}

void sleepNow() {
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
    sleep_enable();          // enables the sleep bit in the mcucr register
    attachInterrupt(0,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
    sleep_mode();            // here the device is actually put to sleep!!
}

void disSleep(){
  // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
    sleep_disable();         // first thing after waking from sleep: disable sleep...
    detachInterrupt(0);      // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time.
}

void loop() {
  wakeVal = digitalRead(wakePin);
  if (wakeVal == HIGH){

    disSleep();

    digitalWrite(led,HIGH);
    delay(1000);

    if (wakeState == LOW){
      Serial.println("Motion detected");
      wakeState = HIGH;
    }
  }
  else{
    digitalWrite(led,LOW);
    delay(1000);

    if (wakeState == HIGH){
      Serial.println("Motion stopped - Going to Sleep Mode !");
      wakeState = LOW;
      delay(1000);

      sleepNow();     // sleep function called here
    }
  }
}


texts: How to fill a triangle using the LCD5110 Graph library?

texts:
Good day! I'm currently trying to create a small 3D engine using C++, an Arduino UNO as well as a Nokia 5110 display with a library. Now I have successfully drawn a cube using triangles, but I want to fill the triangles to add proper lighting. My method for drawing triangles is the following:

LCD5110 lcd(8,9,10,12,11);

void DrawTriangle(int x1, int y1, int x2, int y2, int x3, int y3) {
 lcd.drawLine(x1, y1, x2, y2);
 lcd.drawLine(x2, y2, x3, y3);
 lcd.drawLine(x3, y3, x1, y1);
}

My library hasn't got a triangle draw or fill method unfortunately. I have no idea how I could fill a triangle so I hope for help.

Thanks in advance...

NOTE:
Please keep it simple.

NOTE NR.2: I have already asked this question at StackOverflow but I haven't got a good answer so I will try it again.


texts: 16-Channel 12-bit PWM/Servo Shield check if it is powered by adapter

texts:
I'm using Adafruit 16-Channel 12-bit PWM/Servo Shield with Arduino Uno controller

In setup() I have a number of default positions with PWM commands for motors with plug of USB to PC and turning on

I'm trying to figure out, how to avoid setup() commands, or any other signals during process to servos, in case if shield is not powered from power adapter, which is 6V 8Amp in my case, to not send signal to servo while it is not powered by power supply