texts: Driving power MOSFET from 3.3v or lower Arduino Pro Mini

texts:
I want to control a low voltage (hobby class) motor with a 8Mhz/3.3v Arduino Pro Micro.  I'd like to power both from 2 alkaline cells.  The motor draws approximately 1 A @ 3V with new batteries.  I would be doing PWM of a couple of channels at the normal Arduino rates.

My thought is to connect the batteries to the Vcc pin (not Vraw) and run the Arduino unregulated at about 3V, but somewhat less when the motor is running.  I'm willing to reprogram the fuses for a lower brownout voltage (or none) if needed.

I'm feeling my way on the rest of this - I'll lay out my (perhaps naive) approach and get some feedback about whether I'm understanding it, and how to proceed.

With such a low battery voltage, a TIP120 darlington seems to drop too much voltage and substantially reduce the motor speed/power.  So I'm thinking that I need to use a power N channel MOSFET, and it appears that I need to be fairly selective to get one which can sufficiently turn on with a <3V gate to source voltage.

I'm considering something like the

FQP30N06L http://www.mouser.com/ds/2/149/FQP30N06L-244344.pdf

If I read the datasheet correctly, Vgs of 3V and a load Ids of 1A would result in less than 100mV drop Vds.  But this transistor may be overkill, and the TO220 package is larger than I'd prefer.

If I'm willing to deal with SOT-23-3 surface mount packaging, there are some options like:

Toshiba SSM3K324RLF http://www.semicon.toshiba.co.jp/info/docget.jsp?type=datasheet&lang=en&pid=SSM3K324R
Infineon BSS806NE  http://www.mouser.com/ds/2/196/BSS806NE_Rev2%2001-359816.pdf

If I'm reading it right, with 2x1.5v (nominal) batteries directly powering an Arduino Pro Micro, I can sufficiently drive Vgs to handle 1A Ids at a small Vds and a low enough power dissipation, with any of these three.

I would put a reverse diode and a cap across the motor.  I've seen devices with a small electrolytic across the motor terminals, and I've seen a smaller value ceramic cap - what's the best practices?

Is this a feasible and reasonable approach?  What are the gotcha's that I need to take into consideration?  Any advice about choosing among these (or other) transistors?

My concerns are: not understanding MOSFETs enough, and the unregulated power supply being too noisy for the ATMega328p when it's also powering the motor.  Can I handle the latter by adding another cap or two across the Arduino Pro Micro's Vcc/Ground?

Backup option: run 3x1.5v alkalines and power the Arduino Pro Micro through its regulated Vraw input.


texts: Why is this RISING interrupt repeatedly triggering?

texts:
I've set up an ISR to trigger on the RISING edge of pin #2, but I find that if pin 2 is held high, the ISR triggers repeatedly.

Here's a trace of the voltage measured right at the pin:

I can see a little bit of noise, but it shouldn't be enough to trigger multiple pulses. I've tried both INPUT and INPUT_PULLUP modes for the pin; behavior is the same.

constexpr byte kClockPin = 2;
constexpr byte kReadWritePin = 3;
constexpr byte kLedPin = 13;
constexpr int kNumAddressPins = 16;
constexpr byte kAddressPins[] = {/* MSB */52, 50, 48, 46, 44, 42, 40, 38, 36, 34, 32, 30, 28, 26, 24, 22};
constexpr int kNumDataPins = 8;
constexpr byte kDataPins[] = {/* MSB */45, 43, 41, 39, 37, 35, 33, 31};

volatile bool dirty = false;
volatile uint8_t data = 0;
volatile uint16_t address = 0;
volatile bool read = false;

void setup() {
  // put your setup code here, to run once:
  pinMode(kClockPin, INPUT_PULLUP);
  pinMode(kReadWritePin, INPUT);
  for (byte pin : kAddressPins) {
    pinMode(pin, INPUT);
  }
  for (byte pin : kDataPins) {
    pinMode(pin, INPUT);
  }
  pinMode(kLedPin, OUTPUT);
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(kClockPin), OnClock, RISING);
}

void loop() {
  // digitalWrite(kLedPin, digitalRead(kClockPin));
  if (!dirty) return;
  char output[15];
  sprintf(output, "%04x %c %02x", address, read ? 'r' : 'w', data);
  Serial.println(output);
  dirty = false;
  // digitalWrite(kLedPin, digitalRead(kClockPin));
}

void OnClock() {
  read = digitalRead(kReadWritePin);
  data = 0;
  for (byte pin : kDataPins) {
    data = (data << 1) + (digitalRead(pin) ? 1 : 0);
  }
  address = 0;
  for (byte pin : kAddressPins) {
    address = (address << 1) + (digitalRead(pin) ? 1 : 0);
  }
  dirty = true;
}


texts: I'd like to send  a monitoring information (temperature) to a serial receiver periodically. The problem is I don't know if there is any monitoring service (serial receiver) and how fast it is reading. I only need the latest value. The problem is that serial.write will block if the buffer is full. If I skip writing if the buffer is full, a receiver will only get old data on the first connect. How can I replace data in the buffer or make sure there is only one dataset in the buffer?


texts: 3.5" TFT LCD Display is not working with Arduino Mega 2560 R3

texts:
Even I can't do similarly with my 2.4" TFT LCD in here still: 2.4" TFT LCD Shield isn't working on Arduino Mega

Now, I have bought 3.5" TFT LCD display for my Arduino Mega 2560 R3 to try whether I could run the screen or not, and it is not working now! I am so depressed and angry for these two's misbehaviors. I have already checked website and a lot of Arduino IDE code examples and libraries such as UTFT.h, UTouch.h, UTFT_MEGA, UTFT_CTE, TFTLCD. I tried these and I can not run my 3.5" screen. Where am I faulty? There is something below the screen shield: www.mcufriend.com and 3.5" TFTLCD for Arduino 2560. Are there any basic code or have anyone tried to run Mcufriend's displays correctly?


texts: Why/when to use IoT publish/subscribe protocols rather then RESTful HTTP?

texts:
I am sending data (GPS coordinates) from Arduino once a minute with HTTP POST request to REST API (in OpenShift PaaS). Data is then stored to MySQL db.

Would so called "IoT" publish/subscribe protocols (XMPP, MQTT) be better? Why?

When exactly do you use those two protocols rather than Restful HTTP? Would I really save a significant baterry energy using them?

AFAIK in those protocols machine would "publish" a data to broker and my app would subscribe to it. If I would like to gather data every minute in my app I guess that I would got to have some CRON job that would subscribe to data every minute? Or how would data gathering be achieved?


texts: Possible to drive Waveshare E-ink without driver hat?

texts:
I bought and E-Ink display from waveshare and it came with such a “driver hat”: https://www.waveshare.com/wiki/E-Paper_Driver_HAT#Display_Config_Switch
I am wondering what exactly is the role of this component? Why can’t I directly connect the cables from the display to the GIPO pins and drive the display without the driver hat - given the right software?
(I am also happy to get a pointer to a better forum to ask in if this here isn’t the right place.)


texts: Is it possible to supply Arduino nano with LED-stripe from 12V

texts:
Arduino max amperage is 200mA with 5V supply.
But I can connect arduino with LED-stripe to one 12V 40A power supply in parallel. It gives most balanced power consumption between LED-stripe and arduino (If i understand correctly).
But, I want to control LED-stripe with arduino, and if it turn off all LED on stripe, all amperage will be directed to arduino.
Is it right? And what i must to do (than don't use 5V power supply additional).
Sorry for my worst english. Hope to your help.


texts: Connecting the cathode of a diode to the output of a multiplexer

texts:
From the image, the diodes share the same anode which is driven by 'Do Something'. My question is: through using Arduino IDE, what code should I write that connects the output of the multiplexer (Z) to a specific diode's cathode (Y0 or Y1 or ... or Y7), which in turn is connected to 'Do Something' that drives the cathode probably? In this code, I want the ESP32 microcontroller to connect this cathode to 'Do Something' for say 3 seconds and then switch to the next diode's cathode with a delay of 0.1 seconds [where no diodes' cathodes are connected to Z]       (and so on: in a continuous loop).
Here some code I found online but not sure what needs to be added to get the proper functionality:
int outputs[4] = {4,0,2}; // pins for selecting LED
int inhibit_pin = 15; // pin for turning off all LEDs

void setup() {
  for(int i;i<3;i++){
    pinMode(outputs[i],OUTPUT); // output selection for LED control
  }
  pinMode(inhibit_pin,OUTPUT);
  digitalWrite(inhibit_pin,LOW); // raise high to disable all

}

void loop() {
  // looping through all 8 LEDs
  for (int j=0;j<8;j++){
    // turn on LEDs based on bit conversion
    for(int i=0;i<3;i++){
      digitalWrite(outputs[i],bitRead(j,i));
    }
    delay(100); // delay .1 sec
  }
}

I don't think that "digitalWrite(outputs,bitRead(j,i));" is actually needed and I am not quite sure of what it does.


texts: SD card example freezes at line SD.begin() what should I do?

texts:
I have a 16GB SD card which is formated with FAT32. I'm trying to run the example codes presented for SD in Arduino. The SD card is inserted in the data logging shield and the CS pin in this shield is connected to pin 10.
I first tried the Cardinfo example and this is the result:

The SD card is not empty, there exist a few files in it but this example was unable to show this files.
I then tried the example ReadWrite and the code freezes on line SD.begin(10).
I have no Idea where this problem is coming from.


texts: ESP8266 error: espcomm_upload_mem failed while uploading sketch

texts:
First of all, I would like to apologize for posting this error once again to this community. However, I have been studying articles for last many days to resolve this error. Unfortunately, I did not get any solution which could resolve my problem.

Below is the error which I get when uploading a sketch (even the example sketch):

warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed

Here are the connections:
Vcc - 3.3V
RST - 3.3v
CH_PD - 3.3v
Tx - Rx
Rx - Tx
GPIO0 - GND
GND - GND

I tried various combinations like Tx to Tx, Rx to Rx, pulling off GPIO0. Pulling off reset and ch_pd. Supplying external power source, supplying power directly from Arduino using 3.3V. Supplying power from Arduino 5V using an LD33V regulator. I have even tried uploading the code using USB to TTL. But every time I get exactly the same error.


texts: compare char receive from Slave writer to Master reader with I2C

texts:
Im trying to send data from slave (writer) to master (reader) then compare it to declared 'char p[]' to turn on the lights but somehow i cant make it work.

////master reader

    #include <Wire.h>

int LED = 13;
char p[] = "YES...";

void setup() {
  pinMode(LED, OUTPUT);
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output

}

void loop() {
  Wire.requestFrom(8, 6);    // request 6 bytes from slave device #8

  while (Wire.available()) { // slave may send less than requested
    char c= Wire.read(); // receive a byte as character

  Serial.print(c);         // print the character

  if(c == p){

  digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)

    }else{

  digitalWrite(LED, LOW);   // turn the LED on (HIGH is the voltage level)

          }

  }

  delay(1500);

Slave

//////////////     Slave       ///////////////////////

    #include <Wire.h>

const int pingPin = 8; // Trigger Pin of Ultrasonic Sensor
const int echoPin = 9; // Echo Pin of Ultrasonic Sensor

void setup() {
  Serial.begin(9600); // Starting Serial Terminal
  Wire.begin(8);                // join i2c bus with address #8

}

void loop() {
   long duration, inches, cm;
   pinMode(pingPin, OUTPUT);
   digitalWrite(pingPin, LOW);
   delayMicroseconds(2);
   digitalWrite(pingPin, HIGH);
   delayMicroseconds(10);
   digitalWrite(pingPin, LOW);
   pinMode(echoPin, INPUT);
   duration = pulseIn(echoPin, HIGH);
   inches = microsecondsToInches(duration);
   cm = microsecondsToCentimeters(duration);
   Serial.print(inches);
   Serial.print("in, ");
   Serial.print(cm);
   Serial.print("cm");
   Serial.println();
   delay(1500);

if( inches <= 4){

  Wire.onRequest(requestEvent); // register event
   Serial.print("Obstacle detected");
   Serial.println();
  }
  else
  {

  Wire.onRequest(requestEvent1); // register event
   Serial.print("Nothing Detected");
   Serial.println();

    }

}

// function that executes whenever data is requested by master
// this function is registered as an event, see setup()
void requestEvent() {

  Wire.write("YES..."); // respond with message of 6 bytes
  // as expected by master
}
void requestEvent1() {

  Wire.write("NO...."); // respond with message of 6 bytes
  // as expected by master
}

long microsecondsToInches(long microseconds) {
   return microseconds / 74 / 2;
}

long microsecondsToCentimeters(long microseconds) {
   return microseconds / 29 / 2;
}


texts:
I am developing code to run a word clock and have noticed a slight problem. I am using a DS3231 to keep time, and using the Wire library to communicate with it. I ping the DS3231 every second to get the time and check a few other things. This is all working fine except when the clock loses power. It seems that occasionally upon loss of power to the Arduino, the time that that the DS3231 reports when it regains power, is incorrect.

My thought is that the power is getting cut in the middle of various Wire.read() commands and this is causing the chip to mess up and reset its own time, but I am not sure. The DS3231 has a battery backup attached to it, and that battery has only been plugged in for a month or two, so I don't imagine that is the problem.

I am wondering if anyone has an idea how I can deal with this potential problem, or if there is some way I can clear the Wire library before it starts up again.

I have put some sample code below to give an idea of what I am doing. There is of course much more code, but this is the only relevant part.

#include "Wire.h"
#define kClockAddress 0x68

void readDS3231time(byte * second, byte * minute, byte * hour, byte * dayOfWeek, byte * dayOfMonth, byte * month, byte * year) {
  Wire.beginTransmission(kClockAddress);
  Wire.write(0); // set DS3231 register pointer to 00h
  Wire.endTransmission();
  Wire.requestFrom(kClockAddress, 7); // request seven bytes of data from DS3231 starting from register 00h
  *second = bcdToDec(Wire.read() & 0x7f);
  *minute = bcdToDec(Wire.read());
  *hour = bcdToDec(Wire.read() & 0x3f);
  *dayOfWeek = bcdToDec(Wire.read());
  *dayOfMonth = bcdToDec(Wire.read());
  *month = bcdToDec(Wire.read());
  *year = bcdToDec(Wire.read());
}

void setDS3231time(byte second, byte minute, byte hour, byte dayOfWeek, byte dayOfMonth, byte month, byte year) { // sets time and date data to DS3231
  Wire.beginTransmission(kClockAddress);
  Wire.write(0); // set next input to start at the seconds register
  Wire.write(decToBcd(second)); // set seconds
  Wire.write(decToBcd(minute)); // set minutes
  Wire.write(decToBcd(hour)); // set hours
  Wire.write(decToBcd(dayOfWeek)); // set day of week (1=Sunday, 7=Saturday)
  Wire.write(decToBcd(dayOfMonth)); // set date (1 to 31)
  Wire.write(decToBcd(month)); // set month
  Wire.write(decToBcd(year)); // set year (0 to 99)
  Wire.endTransmission();
}

void setup() {
  // put your setup code here, to run once:
  Wire.begin()
   // DS3231 seconds, minutes, hours, day, date, month, year
   //setDS3231time(0, 36, 10, 2, 21, 12, 15);
}

void loop() {
  // put your main code here, to run repeatedly:
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; // retrieve data from DS3231
  readDS3231time(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);
  delay(1000);
}


texts: How can measure the 3-axis accelerations?

texts:
i'm a student who is studying the Arduino.
I want to measure acceleration using arduino and any sensor. i looked at some acceleration sensors (ex, MPU6050, AXDL335), but they were just measuring gravity, not axial acceleration.

Could you tell me any sensor that can measure the axis-acceleration available with Arduino?


texts: Trying to verify that Arduino Pro Micro ISP is working

texts:
I'm trying to program an Arduino Pro Micro with another Arduino Pro Micro. The purpose is to verify that I can use this Pro Micro board reliably as an ISP to program another Arduino device that does not have a USB interface.

These are actually Pro Micro clones but they seem to work quite well using the Arduino Leonardo profile. I'm following this pinout.

Here is the photo of the setup:

The "red" Pro Micro is set up as ISP using the stock ArduinoISP sketch (didn't think anything needed changing). The "white" Pro Micro is the one I'm trying to program.

The pins are connected, 5V - 5V, GND - GND, MISO - MISO, MOSI - MOSI, SCLK - SCLK, Pin 10 - Pin 10 (reset? this might be wrong).

I've confirmed the ISP sketch is running by the green heartbeat LED. The three LEDs on the red board are connected to pins 7 (top), 8, 9 (bottom), with 9 being the heartbeat.

I loaded the Blink sketch and changed the LED pin to pin 9 since the default pin 14 on the white board is being used as the MISO pin for programming.

In the IDE, I set the board to Arduino Leonardo, port to the red board's port, programmer to "Arduino as ISP" and ran "Upload Using Programmer".

The only output I get is:

avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

Since I'm really just beginning all of this, I'm a bit confused what might be wrong and what could be a next troubleshooting step. Any help appreciated.


texts: Why are begin() functions needed to initialize hardware (if they are)?

texts:
I'm writing a program for an ATmega microcontroller using the Arduino framework.
While implementing an hardware-related class (one to manage LEDs), I put some hardware initialization code such as pinMode(OUTPUT) in the class constructor. Then I realized that in all Arduino libraries I know the hardware initialization is done in a begin() or init(), so I created one for my Led class as well and moved pinMode() there.

Now I'm wondering if I really should define such initialization funcitons, i.e. why they are needed - or, if they are not, why so many libraries have them. I played around a bit and found that for example this code works on an ATmega1284 (it makes the LED on pin 28 light up).

struct Test {
  Test() {
    pinMode(28, OUTPUT);
    digitalWrite(28, HIGH);
    // other stuff
  }
  // ...
};

Test test;

void setup() {
}

void loop() {
}

I presume that this code is somehow ill-conceived, letting alone the fact that it lights up a led without any code in the main function (or maybe that is exaclty the problem?), but if so I can not see why. What did I not consider?
Should the code above be rather writte as in the following snippet, as the existence of all these begin() functions leads me to believe?

struct Test {
  Test() {
    // other stuff
  }
  void begin() {
    pinMode(28, OUTPUT);
    digitalWrite(28, HIGH);
  }
  // ...
};

Test test;

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

void loop() {
}


texts:
I have the notion of putting together a TP cable tester with an arduino. I've seen hacks sending power and lighting up a LED to check continuity, and used a similar 'professional' tester that just plugged into both ends and sent power through one wire at a time, lighting up a LED if it's got continuity aswell.
But, at one of the cables, it had intermittent failures when using it for real data, and often didn't work at all. Swapping out a connector, and straightening what appeared to be a kink in the cable, made it work again.

So, I would like to do a little project where first a regular cable test is performed (check continuity, and that there are no shorts between wires). And if that passes, sending out whatever high frequency an Arduino of any type (from Uno to Mega2560..) can produce, and reading it back on another pin. Using a TP plug in the other end that basically just cross-connects each colored pair, so that a signal can be sent out on one color (say, green) and be received on green-white as it comes back. This would give some hint at the testing end if the cable is okay enough to use with at least a few MHz frequency as opposed to just static DC to light a LED.

After having used a 'plain' cable tester on a 70m cable recently, and us then spending a couple of hours trying to find out why the hecko the full network was seen sometimes but then dropping out again, I'd like to DIY a cheap solution to at least help track down simple problems like this.

(It didn't help matters that when the main switch managed to connect to a single test unit, but freaked out when connected to a switch at the other end as it was supposed to, so for a long time we thought the cable was okay because 'it works just fine with this one unit, must be something in the switch..')

Anyway.. well, I hope you see what I'm getting at. For cheap, testing one pair at a time with some frequency and matching the results or showing dropouts would probably be fine. And having it built into the same unit that first checks for continuity and short circuits means that it can do all the tests without risking shorting out the network buffer/chip on a 'real' machine, like a work laptop.


texts: How to turn off or stop Access Point network in ESP8266?

texts:
I've created a code for ESP8266 12E with Arduino IDE, in which it'll operate as "Station Mode" or "Access Point Mode" on Wifi, depending on the situation. Everything works fine except when device was configured as Access Point, even when I turn off device and then turn on again and force the Wifi initialization as "Station Mode", the Access Point network keeps active.

Example: Let's suppose that I turned on the ESP8266 and initialized the Wifi as Access Point, and named the wifi network as "MY_WIFI_TEST". Let's assume now that I turned off the ESP8266 and forced it to turn on as "Station Mode". The ESP8266 typically connects to my network (the network of my gateway router 192.168.1.1), but keeps the network "MY_WIFI_TEST" active (the prior network as access point). You can not connect to this network, but it remains active.

How can I turn off or stop Access Point network?

My test code:

#include <ESP8266WiFi.h>

bool access_point_init(){
    // Access Point Mode

   Serial.begin(115200);
   IPAddress ip(192,168,1,254);
   IPAddress gateway(192,168,1,1);
   IPAddress subnet(255,255,255,0);
   char* ssid     = "myssidname";
   char* password = "12345678";

   WiFi.softAPConfig(ip, gateway, subnet);
   bool ret = WiFi.softAP(ssid, password);

   return ret;
}

void wifi_station_init(){

    // Station Mode
    Serial.begin(115200);
   Serial.printf("\n");

   WiFi.begin(net_ssid, net_pwd_ssid);

   IPAddress ip(192,168,1,10);
   IPAddress gateway(192,168,1,1);
   IPAddress subnet(255,255,255,0);

    WiFi.config(ip, gateway, subnet);

   k = 0;
   while ((WiFi.status() != WL_CONNECTED) && (k < 80)){
      delay(250);
      Serial.print('.');
      k++;
   }

   Serial.printf("\n");
   Serial.printf("IP address: ");
   Serial.println(WiFi.localIP());
}

void setup()
{
    bool my_condition = false;
    //...
    // my_condition = myLoadFunction();
    //...

   if (my_condition) {
        access_point_init();
   } else {
      wifi_station_init();
   }
}


texts: 'crash' when using pin change interrupts

texts:
I'm noticing a crash when testing out some interrupt code for a project I'm working on.

I've returned to the example provided with the library PciManager and I'm still experiencing the same issue. There doesn't appear to be any patten to when the crash appears, and on occasion I've been playing for several minutes and not seen a crash. NOTE I had to add a file (Task.h) from the developers other project (SoftTimer) to get it to compile.

here is the code:

#include <PciManager.h>
#include <PciListenerImp.h>

#define INPUT_PIN 3

PciListenerImp listener(INPUT_PIN, onPinChange);

int i = 0;

void setup() {
  Serial.begin(9600);
  PciManager.registerListener(INPUT_PIN, &listener);
  Serial.println("Ready.");

}

void onPinChange(byte changeKind) {
  i++;
  Serial.print("pci : ");
  Serial.print(i);
  Serial.print(" : ");
  Serial.println(changeKind);
}

void loop() { }

I have a wire connected to pin 3 and 3.3v which I'm pulling out and then connecting again. Some times when disconnected it continually interrupts, I was expecting this. Sometimes it doesn't which I found strange, the crash appears to happen more in the latter case.

Here is a trace from the serial monitor

Ready.
pci : 1 : 0
pci : 2 : 1
pci : 3 : 0
pci : 4 : 1
pci : 5 : 0
pci : 6 : 1
pci : 7 : 0
pci : 8 : 1
pci : 9 : 0
pci : 10 : 1
pci : 11 : 0
pci : 12 : 1
pci : 13 : 0
pci : 14 : 1
pci : 15 : 0
pci : 16 : 1
pci : 17 : 0
pci : 18 : 1
pci : 19 : 0
pci : 20 : 1
pci :

I've run this on a shrimp and on a freeduino diecimila compatible board both resulting in the same effect.

Anyway down to question; is the issue the way I'm interrupting? i.e. not stopping the floating pin? or is it a problem with the library, or is it a fundamental problem with pin change interrupts.


texts: Is it possible to connect 2 ultra sonic sensors to 1 arduino?

texts:
I am currently using the Arduino Pro Micro board and I want to connect 2 ultrasonic sensors to 1 board, whilst knowing which sensor is being triggered. The sensor I am using is a HC-SR04 Ultrasonic sensor.

Please help me thank you :)


texts: Help to understand multiple PWM working together

texts:
I'm very new to arduino related stuff so this question might be really easy to answer.
I don't understand how multiple PWM outputs are supposed to work. Look at the pic.

In the first(1) case we are using short signal width which would be close to motor staying still. In this case, as can be seen, short pulses follow each other, so does the code.

motor1.writeMicroseconds(shortWidth);
motor2.writeMicroseconds(shortWidth);
motor3.writeMicroseconds(shortWidth);
motor4.writeMicroseconds(shortWidth);

when motor4 ended it's output, motor1 starts it's pulse again causing non-problem consequent pulses.

In the second(2) case pulse is wider which corresponds to setting motor speed close to maximum. After motor1 finishes generating width, it's time for motor2 to generate one. But when it does, motor1's period comes to end and it has to start generate width again, but arduino is busy generating pulse of motor2.

How does PWMs work in this case?


texts: Strange problem with serial communication

texts:
I'm developing a little project with Arduino, using a small web page to show data. Well, I have been develop the web page and the small code to communicate with Arduino board in my local computer and all work fine.
But, after, I uploaded the code to a Raspberry Pi and then the problems appear.
This is very strange, because when I execute the code inside a WSGI like  django (in my case is other, webapp2) the code works well. I call a specific URL and this WSGI call a method inside a class that communicated with the Arduino board through serial port, so far, so good.
The problem appears when I decided build a method to execute the lines that do the communication, in this moment Arduino does not response and only lights the led number 13 and the 'L' led twice (the led inside the board).

I don't understand why this happens. The code is exactly the same. Any idea?

For the other hand, because I don't have GUI in the raspberry I don't can view the serial port communication easy.
Do you  know any way to view or debug the serial communications between a pc and Arduino without GUI, over the command line?

This is the code:

# -*- coding: utf-8 -*-
import serial
import time

arduino=serial.Serial('/dev/ttyACM0', baudrate=9600, timeout=3.0)
arduino.close()
arduino.open()

sensorTemp=''
arduino.write('a')
while arduino.inWaiting() > 0:
        sensorTemp+=arduino.read(1)
print sensorTemp

Thanks you so much. Any idea is welcome.


texts: Arduino ESP8266 module communicate through Arduino IDE terminal

texts:
I am completely new to Arduino and trying to setup the Arduino and ESP8266 module. Thereby I used this scheme to set it up:

Where I use this code:

`#include <SoftwareSerial.h>

const byte rxPin = 1; // Wire this to Tx Pin of ESP8266
const byte txPin = 0; // Wire this to Rx Pin of ESP8266

// We'll use a software serial interface to connect to ESP8266
SoftwareSerial ESP8266 (rxPin, txPin);

void setup() {
  Serial.begin(9600);
  ESP8266.begin(9600); // Change this to the baudrate used by ESP8266
  delay(1000); // Let the module self-initialize
}

void loop() {
//  Serial.println("Sending an AT command...");
  ESP8266.println("AT");
  delay(30);
  while (ESP8266.available()){
     String inData = ESP8266.readStringUntil('\n');
//     Serial.println("Test: " + inData);
  }
}`

But I am trying to communicate through the terminal in the Arduino IDE want to type AT and it sends me back "OK". How can I achieve this?


texts: Interleave disassembly + source with avr-objdump

texts:
I have a C program for the attiny85, that I want to disassemble and display with interleaved source code.

Here's my program:
test.c

#include <avr/io.h>
int main() {
    for(int i=0; i<100; i++) {
        PORTB=i;
    }
}

Here's how I compile it: avr-gcc -g -O0 -mmcu=attiny85 -o test.elf test.c

Finally, I generate the disassembly with interleaved source-code with the command: avr-objdump -S -D test.elf

The disassembly of the text section shows the following disassembly without interleaved source code:

00000030 <main>:
  30:   cf 93           push    r28
  32:   df 93           push    r29
  34:   00 d0           rcall   .+0             ; 0x36 <main+0x6>
  36:   cd b7           in      r28, 0x3d       ; 61
  38:   de b7           in      r29, 0x3e       ; 62
  3a:   1a 82           std     Y+2, r1 ; 0x02
  3c:   19 82           std     Y+1, r1 ; 0x01
  3e:   0a c0           rjmp    .+20            ; 0x54 <__SREG__+0x15>
  40:   88 e3           ldi     r24, 0x38       ; 56
  42:   90 e0           ldi     r25, 0x00       ; 0
  44:   29 81           ldd     r18, Y+1        ; 0x01
  46:   fc 01           movw    r30, r24
  48:   20 83           st      Z, r18
  4a:   89 81           ldd     r24, Y+1        ; 0x01
  4c:   9a 81           ldd     r25, Y+2        ; 0x02
  4e:   01 96           adiw    r24, 0x01       ; 1
  50:   9a 83           std     Y+2, r25        ; 0x02
  52:   89 83           std     Y+1, r24        ; 0x01
  54:   89 81           ldd     r24, Y+1        ; 0x01
  56:   9a 81           ldd     r25, Y+2        ; 0x02
  58:   84 36           cpi     r24, 0x64       ; 100
  5a:   91 05           cpc     r25, r1
  5c:   8c f3           brlt    .-30            ; 0x40 <__SREG__+0x1>
  5e:   80 e0           ldi     r24, 0x00       ; 0
  60:   90 e0           ldi     r25, 0x00       ; 0
  62:   0f 90           pop     r0
  64:   0f 90           pop     r0
  66:   df 91           pop     r29
  68:   cf 91           pop     r28
  6a:   08 95           ret

The disassembly makes somewhat sense, only that I miss the interleaved source code.

Interestingly enough, the output also includes a stab section, where I also find the main segment disassembled:

#include <avr/io.h>

int main() {
  30:   20 00           .word   0x0020  ; ????
  32:   00 00           nop
  34:   80 00           .word   0x0080  ; ????
  36:   00 00           nop
  38:   00 00           nop
    for(int i=0; i<100; i++) {
  3a:   00 00           nop
  3c:   40 00           .word   0x0040  ; ????
  3e:   00 00           nop
        PORTB=i;
  40:   80 00           .word   0x0080  ; ????
  42:   00 00           nop
  44:   00 00           nop
  46:   00 00           nop
  48:   5a 00           .word   0x005a  ; ????
    for(int i=0; i<100; i++) {
  4a:   00 00           nop
  4c:   80 00           .word   0x0080  ; ????
  4e:   00 00           nop
  50:   00 00           nop
  52:   00 00           nop
  54:   91 00           .word   0x0091  ; ????
  56:   00 00           nop
  58:   80 00           .word   0x0080  ; ????
  5a:   00 00           nop
  5c:   00 00           nop
  5e:   00 00           nop
  60:   b7 00           .word   0x00b7  ; ????
    }

}

Now the output includes source code, but the disassembly is wrong.

How do I get an output were both is correct: the disassembled instructions and the interleaved source-code?

(avr-gcc (GCC) 9.3.0. Interleave Assembly and Source for avr-objdump does not seem to have the problem, although he's using the same compiler flags...)


texts: Arduino write to memory and self shut down (over MOSFET) - An idea help

texts:
i would like to ask you for help with design of an circuit.

I have and atmega328p, with detection for voltage on its Vin (Vcc).
I have made and voltage divider and its output i connected to Analog Pin. And i would like to, if an voltage decrease under an certain level (4.5V), to shutdown itself (atmega328p).

As i said the voltage detection is no problem (there is an voltage divider), programing it is as well no problem, but i though that i program it like this:

  Detect voltage on analog pin A0, if the voltage is less than certain
  level (4.5V), write to memory and send to digital pin 3 an "LOW" (0)
  logical state.

This will turn the mosfet off and the atmega will loose its ground (GND) and its shuts down, but i have there an pull-up resistor which when the atmega shutsdown takes its lead an set Gate at MOSFET to high (transistor will turn on) and atmega turns on, then it shuts down and this will do the infinite cycling until there's no power to turn on atmega.

I want to use an Supercapacitor (2.2F 5.5V) to power it when the main input is lost and to give an atmega a time to write to memory and steadily turns off.

I am adding an schematics to better look at the problem.

I know that there is no crystal and capacitors and the other things to make it reliable and fully functional, but this is not a subject of this question.Its an first sketch, which is not completed.

I know some ICs that can detect Voltage and turn its output to some logical state (1 or 0), like an MAX809 (803 or 810) and so on and of course this is my backup plan, but i want to ask you, if you have any great idea to make this without any special ICs and more easily? I also thought about some OPamp or thyristor maybe, i don't know......

Can you help me with an idea or better with an schematics how to do it ? Thanks.


texts: Is there a Arduino UI library that provides dialog box and button functionality at a minimum?

texts: I have been looking at the Arduino TFT Library and it supports all the bits and pieces for making a simple display, but I am looking for something a little higher level that has primitive dialog box and button capability, and presumably, the ability to layer the display so I can push and pop display elements.  Is there a higher level GUI library for Arduino TFT displays?


texts:
I am strain guages in a wheatstone bridge along with hx711 . For testing amplifier I used potentiometers to change the input voltage for hx711. It is outputting only zero. Here is my code.

#include "HX711.h"

// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;

HX711 scale;

float calibration_factor = 282650.0;

void setup() {
  Serial.begin(57600);
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale();
  scale.tare(); //Reset the scale to 0
}

void loop() {
  if (scale.is_ready()) {
    long reading = scale.read();
    Serial.print("HX711 reading: ");
    //Serial.println(reading);
    Serial.println(scale.get_units(), 5);
  } else {
    Serial.println("HX711 not found.");
  }
  delay(1000);
}


texts:
I am making a small project (BT controlled "tank") and need to connect ESP32 with HC-06 (ESP32 will be in controller and HC-06 in the vehicle). Android phone communication with both ESP and HC-06 works prefectly, I can not just figure out, how to pair/connect these two modules. Any ideas?

EDIT: Just to clarify, I can not connect them, because the HC-06 has PIN and I can not figure out how to remove that PIN or connect to it with PIN from ESP32...


texts: Where is documentation on Arduino's Internal Interrupts?

texts:
First time arduino programmer here...however I have programmed the TI MSP430 in the past...

I am trying to figure out how to configure internal Interrupt Vectors on this Arduino Uno.

In the Arduino IDE, I am skeptical about writing lines of code like

ISR(TIMER1_CAPT_vect) {
    Serial.Print("Entered Capture Vector");
}

Because it doesn't appear to matter what I type inside ISR(), for instance I can write
    ISR(GibERisH) {
    }

And it still compiles and uploads to the arduino. What?! Also how could Arduino IDE know what the heck TIMER1_CAPT_vect is without having the library?

I found a list of interrupt vector names here: http://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html

But I can not find documentation ANYWHERE ELSE on what to call these interrupt vectors.

Should I abandon the Arduino IDE and go with the Atmel Studio 6.2 (There is a juicy looking arduino plug-in...)? I need advanced control of the guts of this processor, and there is zero documentation about how to do this anywhere on the internet.

EDIT: I realized my problem was I was looking for documentation for the atmega16U2 (that does something else on the board), not the atmega328P.


texts: The ATmega328P has a separate clock signal for Flash and EEPROM (CLKFLASH) than it has for the RAM (CLKCPU). Why is this?


texts:
I am searching for a tiny board to that accepts an usb-c cable and outputs 5v.
To my understanding, for the few hundred milliamps two 5k1 resistors on the board would suffice. PD is not needed.
I already bought this, but sadly it's too big. Also, I don't need any data pins, just 5v and -.
Can anyone recommend such a board to power a tiny circuit?


texts:
Can you help me with the codes? I have gizduino(arduino clone), i used the codes in receiving sms from the internet but what i receive is a symbol "y" with two dots at the top. Whats wrong?

My gsm is set to suart.

// Example 55.4

#include <SoftwareSerial.h>
SoftwareSerial SIM900(2,3);

char incoming_char=0;

void setup()
{
  Serial.begin(19200); // for serial monitor
  SIM900.begin(19200); // for GSM shield
  SIM900power();  // turn on shield
  delay(20000);  // give time to log on to network.

  SIM900.print("AT+CMGF=1\r");  // set SMS mode to text
  delay(100);
  SIM900.print("AT+CNMI=2,2,0,0,0\r");
  // blurt out contents of new SMS upon receipt to the GSM shield's serial out
  delay(100);
}

void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
  digitalWrite(9, HIGH);
  delay(1000);
  digitalWrite(9, LOW);
  delay(7000);
}

void loop()
{
  // Now we simply display any text that the GSM shield sends out on the serial monitor
  if(SIM900.available() >0)
  {
    incoming_char=SIM900.read(); //Get the character from the cellular serial port.
    Serial.print(incoming_char); //Print the incoming character to the terminal.
  }
}


texts: Combining two different coding program into one sketch

texts:
Im working on project that uses a relay module,arduino atmega328 and a 2 motor 12vdc. based on coding i give, the first code is the motor 1 will run based on the input switch. and the second code the motor will run based on the delay time. what im doing is, im going to combine these two coding into one sketch hoping these two coding will run together. but im confused on how to combine.

`int motorPin = 10; // pin that turns on the motor
int blinkPin = 9; // pin that turns on the LED
int watertime = 5; // how long to water in seconds
int waittime = 60; // how long to wait between watering, in minutes

void setup()
{
  pinMode(motorPin, OUTPUT);
  pinMode(blinkPin, OUTPUT); // set pin 13 to an output so we can use it to turn on the LED
}

void loop()
{
  digitalWrite(motorPin, HIGH); // turn on the motor
  digitalWrite(blinkPin, HIGH); // turn on the LED
  delay(watertime*3000);        // multiply by 1000 to translate seconds to milliseconds

  digitalWrite(motorPin, LOW);  // turn off the motor
  digitalWrite(blinkPin, LOW);  // turn off the LED
  delay(waittime*6000);        // multiply by 60000 to translate minutes to milliseconds
}`

this is the coding to run the motor by using delay time

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

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

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

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

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

this is the code which the motor will run based on the switch

for now, i dont have idea on how to combine these two coding.

the idea of my project is when switch is LOW(pin 3)  the Motor 1(pin 13) will HIGH until the switch is HIGH, the motor 1 will be LOW and stop.  At the same time,  there will be time delay for 10 second and the Motor 2 (pin 10)will active soon after switch is LOW and delaying time for 10 seconds and the Motor 2 will be active with time for 25 second  and stop and the next active for another 60 minutes


texts: Arduino Nano not visible in Serial Ports (Mac OS)

texts:
I have used by Arduino countless times over the past few years and only after installing an update to Mac OS Sierra did the device stop showing up under the Serial Ports. Now only tty-bluetooth shows up no others. I have looked a countless threads where people suggest installing drivers or uninstalling drivers or rebooting. I have tried everything but still no device shows up.

I switched to my Windows partition using Bootcamp and lo and behold it works perfectly there but not in Mac OS. I would still like to use Mac OS to programme my Arduino. If anyone has any suggestions I would be very grateful!


texts: DHT11 sensor not working on ESP8266, no response

texts:
recently Ive set up an ESP8266 to control temperature and humidity in rooms, for this Im using DHT11 sensor, thats the basic code I have in order to check functionality in Arduino IDE
#include "DHT.h"
#define DHTPIN A0
#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  Serial.println("DHT11 Testprogram");
  dht.begin();
}
void loop() {
  // Wait a few seconds between measurements.
  delay(2000);

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    Serial.println("Error");
    return;
  }

  Serial.print("Luftfeuchtigkeit: ");
  Serial.print(h);
  Serial.print("%\t");
  Serial.print("Temperatur: ");
  Serial.print(t);
  Serial.write('°');
  Serial.println("C");
}

So far as I've checked the code seems to be all right and doesn't have any issues. The bottleneck might be the circuit although I checked twice and I don't really understand what the issue still might be.

the 3V is connected to the + and to the pull up resistor of the sensor which is 10K and A0 Pin according to the plan with data pin of the sensor as well as with a pull up resistor and G is connected to - of the sensor. I still get no response from the sensor, I even checked other 3 sensors and cannot understand what the issue might be, does anyone know a solution?


texts: Use AGPS functionality with Arduino and GPS module

texts:
Recently, we developed the UTRAQ L100 GNSS Module base board for testing all the capabilities of the GPS receiver.
https://www.elementzonline.com/blog/utraq-gps-l100-module-based-on-irnss-supported-by-gagan-navic
But we couldn't find a way to use the AGPS functionality. Is there any AGPS server available that can be used to download the satellite ephemeris data and feed that to the GPS module?
I got a reference that uses Skytraq AGPS, but not sure if the same is applicable for all receivers with AGPS functionality.
https://github.com/r0ro/skytraq
The above reference uses python code, but hopefully, it can be ported to an Arduino library if the functionality actually works well.


texts:
Just wondering whether it is possible to create 'virtual analog' signals, I am designign a system that uses a tank level sensor (pressure transducer); the component has not yet arrived and I am expecting it in a few weeks.

Is there any way to simulate the signals it would spit out, using some sort of GUI where I can physically control the 'virtual' tank level?

I'm thinking something along the lines of Wonderware's Intouch?

Would appreciate the help! Thanks


texts: Bluetooth module HC-05 firm 3.0, master connection impossible

texts:
I recetly acquired a Bluetooth Module for Arduino, the HC-05.
My project is to create a dashboard thanks to ELM327 Bluetooth OBD.
But my HC-05 is with firmware 3.0, and during my research I discover different problems with this version, and one is the impossibility to configure in Master,
My different steps :
Check connection
AT
OK

Re-init with default paramters
AT+ORGL
OK

Erase paired devices
AT+RMAAD
OK

Set in master
AT+ROLE=1
OK

Restart after change role
AT+RESET
OK

Autorise connection to any address
AT+CMODE=1
OK

Configure search mode (standard, stop after 5 devices or 5 seconds)
AT+INQM=0,5,5
OK

Password
AT+PSWD=1234
OK

Run SPP profile
AT+INIT
Error(17)

Thanks to my reseach : With firmware 2.0 : First time OK, next time Error(17)
With firmware 3.0 : First time and next Error(17)
datasheet (https://drive.google.com/file/d/0B4urklB65vaCUzZQVFJPZWxhNFk/view) : Error(17) : SPP lib has been repeated initialization.
Start research
 AT+INQ
 Error(1F)

Absolutely any idea what is this error
If I try to connect to my ODB (or my other HC-05 (in slave) on anthoer Arduino), in use my phone to find MAC address and I re-format it
PAIR : OK
BIND : OK
LINK : FAIL
So if anyone have an ideas or I already meet this problems and can help me,
Or if you know very simple and reliable master bluetooth module for Arduino
Thanks


texts: Can anyone explain me the difference between the symbols for Arduino nano in KiCad? Is there any important difference at all? All of them seem to have all basic pins.


texts: Adafruit 2.8 TFT LCD Touchscreen 4 wire pins - unclear instructions

texts:
Warning - Noob question

I am trying to follow the instructions provided by the vendor https://learn.adafruit.com/2-8-tft-touch-shield/touchscreen-paint-example to no avail. Specifically:

  We connect the 4 pins as follows:
  Y+ is connected to Analog 1
  Y- is connected to Digital 7
  X+ is connected to Digital 6
  X- is connected to Analog 2

My board looks like this

and I cannot see any X/Y/+/- labelled pins. I then found the schematic of the board

https://github.com/adafruit/Adafruit_2.8_Inch_TFT_Shield_PCB/blob/master/schem.png

where these pins are labeled but what is the representation of the schematic on the board?

Finally, once I do find the pins, how do I connect them if they are already used? Do I have to use a breadboard?

Edit: After the helpful comments of jsotola, I got a photo:

Are these the 4 "pins"? If so, how on earth do I connect these to the arduino?


texts: Unreliable serial communication from Arduino Mega

texts:
I'm using an Arduino Mega to send serial commands to a device that supports RS485 or RS422 half-duplex. To do this, I'm using the following code:

bool foo(int A, int B)
//...
//Const global int to byte 1&2
//Math on int A and int B to make bytes 3-8
//...
  unsigned char cmd[8]={[byte1],[byte2],[byte3],[byte4],[byte5],[byte6],[byte7],[byte8]};
  while(rep)
  {
    for (int i=0; i< 8; i++)
    {
      Serial2.write(cmd[i]);   // Send C string
    }
    if(Serial2.available())
    {
      //device echoed == command recieved
      rep=false;
    }
  }

The odd thing is that sometimes the loop gets it right on the first try, other times it takes 50+ tries to receive a command. This makes me think that there is something in my code that is making the data transmission unreliable. I believe it could be one of the following three things.

I still need an RS485 module

In a previous version of my software, I was using the software serial library and used an RS485 module similar to the one shown here:

As I'm no longer using the software serial library and instead using the Mega's Serial2 port, I thought I could get rid of the module. Is this incorrect? If so, why would the commands work after N attempts as opposed to never working at all?

Looping the Serial2.write()

Previously, while using the above module, I had to have two lines of code that would shift the DE and RE pins high or low depending on if I was sending or receiving data. I realized that these needed to be outside the for (int i=0; i< 8; i++) loop as otherwise, the device would not be able to read/understand the data being passed. Do I need to reimplement some version of this with the Arduino Mega's native serial? If so, how would I do this?

I'm Not supporting a tri-state the transmit buffer

I was rereading the device's manual and found this line:

  The converter must have the hardware and software support to tri-state the transmit buffer following the message transmission.

Honestly, I have no idea what this means. Does Arduino do this? If not, how can I make this happen?

Additional things of note:

I'd much rather use something like Majenko's pointer way to send data to my device so that I could make the code not rely on the fact that there are always 8 bytes transmitted. However, sometimes a byte will be \0 (or any other termchar) which would stop the loop prematurely. Is there a way to avoid this?
I'm still pretty new here, Is there some way that I can do this better than the way I'm currently doing it?


texts: Question about infrared receiver with metal shell to detect heart pulse rate?

texts:
I'm newbie to the world of arduino and environmental sensing. I have been searching for a while about how can I measure the heart pulse rate, I came through the following tutorial:

Click Here

I have the following Arduino IR Receiver with metal shell module that I want to use as the previous tutorial suggesting, but, the IR receiver used in the tutorial has no metal shell, so, my question is if they are both functioning the same way?
Can I position my IR Receiver exactly as the one in the tutorial or do I need some workaround to reach my goal based on the fact that it has a metal shell?
Thanks in advance.


texts: HC-05 and HC-06 Bluetooth not communicating well

texts:
I am trying to communicate between two Arduino UNO. One has a HC-05 which is configured as master, the other Arduino has HC-06 which is the slave. What I want to achieve is to be able to print a character on the Serial monitor of the slave Arduino when a button on the master Arduino is pressed. I have been able to pair the two and once they are powered, they connect automatically. When I press a button on the master, what I get on the serial monitor of the slave is the 254 instead of the character 'a' which is what I am sending from the master. I have tried changing the data type, and also switched the code for master and slave, but the problem persists. I have also used hardware serial instead of software serial. My HC-05, and HC-06 works well when paired with android phone and can send and receive useful data. My code is as shown below:

CODE FOR MASTER:(SENDER)

#include<SoftwareSerial.h>
const int rxPin = 10;
const int txPin = 11;
const int button = 2;

SoftwareSerial masterSerial(rxPin,txPin);//RX,TX.

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

void loop() {

   int buttonVal = digitalRead(button);
   if(buttonVal==HIGH){
       masterSerial.write('a');
      delay(1000);
   }
//mySerial.flush();
}

CODE FOR SLAVE( RECEIVER)

#include<SoftwareSerial.h>

const int rxPin = 10;
const int txPin = 11;

int incomingByte = 0;

SoftwareSerial slaveSerial(rxPin,txPin);//RX,TX.

void setup() {

   pinMode(13, OUTPUT);
   Serial.begin(9600);
   slaveSerial.begin(9600);

}

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

   while(slaveSerial.available()){
      incomingByte = slaveSerial.read();
      delay(3);
      Serial.println(incomingByte);
    }
}


texts:
I am trying to design a circuit that wakes my ESP8266 (Wemos D1 Mini) from deep sleep using a shock sensor. I can achieve this using the reset pin but I need
it to ignore further requests to reset to give it time to run the code in my sketch. Provided there is still motion it will just continue to reset meaning the code only gets run after the 'shock' stops. I have tried all kinds of things with capacitors and transistors to delay subsequent resets but with very limited success. Can someone please point me in the right direction or suggest an easier way to do this? Many thanks in advance.


texts: Why does my 23,032 byte Arduino sketch take 36.32 sec to upload via ISP to an Atmega328p on a breadboard w/code verification disabled?

texts:
"Sketch uses 23032 bytes (71%) of program storage space. Maximum is 32256 bytes.
Global variables use 1342 bytes (65%) of dynamic memory, leaving 706 bytes for local variables. Maximum is 2048 bytes."
I have "verify code after upload" disabled. With this enabled, it takes an additional 20 sec to upload for a total of 56 sec.
Using Sparkfun's avr programmer with USBtinyISP, win 10, arduino ide, minicore library. Code is utilizing several libraries from Mozzi. External 16mhz crystal. Have set fuse bits on the chip to use the external clock using the following command: "avrdude -c usbtiny-p m328p -U lfuse:w:0xFF:m"
Seems like it should be faster if truly uploading at 115200 bits / sec. But maybe I'm missing something in how this works.
Thanks !!


texts: How to send an email with Arduino and a WiFi shield?

texts:
I want to make my Arduino connect via WiFi and then send an email. The idea is very simple, but the problem is that I've never worked with those protocols and other things before. I just wanted something that's already premade, so I would just change the information.

Is there a library or a function that sends the email?

If someone could help me to understand, so I can make it myself, that would be the best.


texts: IRremote sending only works once with Arduino Nano

texts:
I am trying to control a receiver, wich is not working. I believe i have to send the code at least three times... but after the first time the IR Led stays off. I am using the Arduino Nano with the LED connected to pin 13. The "Send" message keep printing.

I am using this lib: https://github.com/Arduino-IRremote/Arduino-IRremote
I tried multiple versions of the lib

My code:
#include <IRremote.h>

IRsend irsend;

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

const static unsigned int raw[68] = {8950,4450,550,550,600,550,600,500,600,550,550,550,600,500,600,550,600,500,600,1600,600,1600,600,1650,550,1650,550,550,600,1600,600,1600,600,1650,550,550,600,1600,600,1600,600,550,550,550,600,500,600,550,550,550,600,1600,600,550,550,550,600,1600,600,1600,600,1600,600,1600,600,1650,550};

void loop() {
  Serial.println("Send");
  for (int i=0; i<3; i++) {
    irsend.sendRaw(raw,68,38);
    delay(40);
  }
  delay(5000);
}

Works only again once when resetting the Arduino


texts: How to insert into table in database after every 5 minutes using Real time clock module

texts:
I have RTC module attached to arduino mega,

to calculate time difference of minutes I am getting minute from the RTC module

and checking if passed time is greater than 5 minutes  then insert to MySQL table in database.

  int mint = util::getMinute();

  if (util::getMinute() - mint >= 5)

  {
    // inserting to sql database on mysql server
    INSERT_SQL = "";
    INSERT_SQL.concat("INSERT INTO arduinoSensorData.outTempLog (out_temperature) VALUES ('");
    INSERT_SQL.concat(tempInC);
    INSERT_SQL.concat("');");

    const char *mycharp = INSERT_SQL.c_str();
    delay(1000);

    if (!connected) {
      my_conn.mysql_connect(server_addr, 3306, user, password);
      connected = true;
    }
    else if (connected == true)
    {
      delay(500);
      Serial.print("Inserting : ");
      Serial.println(INSERT_SQL);
      Serial.println("Connection Successfull,inserting to database.");
      my_conn.cmd_query(mycharp);

    }
    else {
      Serial.println("Connection failed.");
    }
    mint = util::getMinute();
  }

the full code is here


texts: wrong leds lit in matrix display - wrong coding?

texts:
I wrote the following code for displaying a bitmap (small size) on a  LED matrix (formed using APA102 led strip):

//for 24-bit bitmaps

// the header files for the RGB data

 #include <FastLED.h>
 #include "redarray.h"
 #include "greenarray.h"   //g data header file (hex or dec)
 #include "bluearray.h"   //b data header file (hex or dec)*/

//matrix parameters

#define MatrixWidth 36 //columns
#define MatrixHeight 7 //rows
#define numled (MatrixWidth * MatrixHeight)

//pin details

#define datapin 7

#define clockpin 8

CRGB leds[MatrixWidth * MatrixHeight];

const bool  MatrixSerpentineLayout = true;

 void setup() {

     FastLED.addLeds<APA102, datapin, clockpin>(leds,numled);
     FastLED.clear();
  }

void loop() {

  for(uint8_t x=0 ; x<MatrixWidth ; x++)  {

      for(uint8_t y=0; y < 3; y++) {

            leds[XY (x, y)].setRGB(redarray[x][y],greenarray[x][y],bluearray[x] [y]);

           FastLED.show();

           delay(1);
         }
      }
   }

      uint16_t XY( uint8_t x, uint8_t y)
 {
   uint16_t i;

     if( MatrixSerpentineLayout == true) {
       if( y & 0x01) {
        // Odd rows run backwards
          uint8_t reverseX = (MatrixWidth - 1) - x;
          i = (y * MatrixWidth) + reverseX;
     } else {
       // Even rows run forwards
          i = (y * MatrixWidth) + x;
    }
   }

  return i;
}

The following is the data in one of the header files - its of same type for the other two colors.

const unsigned char redarray[36][3] PROGMEM  = {
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x20, 0x20, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x20, 0x20, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x20, 0x20, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
};

The matrix is in a serpentine form (evident from the XY function in code). I am using an Arduino Due. The problem is that the code compiles and runs...but the bitmap is incorrect. Although I am sure, I am somewhat along the correct path because some LEDs do light up as they should as per the bitmap. But most of them are wrongly lit.

Could you somebody plz guide where I am going wrong with the coding? I fear there is some mistake in reading the color data from array and allocating it to leds[XY(x,y)].I do not know how a 2D array is read or dealt with by Arduino.

Thanks!


texts: Streaming sensor data over UDP using an Arduino Yún - how to do it and how fast could it be?

texts:
The company where I work wants to do a proof of concept for our new product, a force-sensing platform.

The platform contains four three-axial load cells, so we have 12 channels, which are to be digitized at 2kHz and 16bits. This gives us 2.000 dataframes per second, with 24 bytes of payload each.

Our proposed architecture is as following:

The analog signals from the cells is acquired by a dedicated data-acquisition board;
The digital stream is sent to the ATmega on Yún over SPI;
The data is then relayed to the Atheros over Serial;
Finally, the data is transmitted over UDP (or TCP).

I wonder if it is a sensible way of doing it, with the following questions:

How would one normally use the Ethernet functionality? Can I call a function on the sketch, or do I need to put some program or script in the Linux, calling it from the sketch?
What would be the maximum transmission speed (in bytes per second) from the ATmega side to the Linux side?
What would be the maximum throughput of the Ethernet?

I have calculated 24 bytes * 2000 = 480 bytes per second, or a baud rate of 480 * 8 = 3840bps. Is that right?

I would appreciate any help, it could be just a link to the proper information resources.


texts: What is corrrect the way to find roll, pitch, yaw?

texts:
I have an MPU9250. I have calculated accelerometer, gyroscope, magnetometer. But I want to know how to caclulate roll yaw pitch. I have searched on Google. I found many answer

roll  =  (atan2(-Accel_Y, Accel_Z)*180.0)/M_PI;
pitch =  (atan2(Accel_X sqrt(Accel_Y*Accel_Y + Accel_Y*Accel_Y))*180.0)/M_PI;

source: https://theccontinuum.com/2012/09/24/arduino-imu-pitch-roll-from-accelerometer/

   accelerationX = (signed int)(((signed int)rawData_X) * 3.9);
   accelerationY = (signed int)(((signed int)rawData_Y) * 3.9);
   accelerationZ = (signed int)(((signed int)rawData_Z) * 3.9);
   pitch = 180 * atan (accelerationX/sqrt(accelerationY*accelerationY + accelerationZ*accelerationZ))/M_PI;
   roll = 180 * atan (accelerationY/sqrt(accelerationX*accelerationX + accelerationZ*accelerationZ))/M_PI;
   yaw = 180 * atan (accelerationZ/sqrt(accelerationX*accelerationX + accelerationZ*accelerationZ))/M_PI;

source:  https://engineering.stackexchange.com/questions/3348/calculating-pitch-yaw-and-roll-from-mag-acc-and-gyro-data

  Accroll = atan2( accy / (accy^2 + accz^2) )
  Accpitch = atan2( accx / (accx^2 + accz^2) )

source: http://franciscoraulortega.com/pubs/Algo3DFusionsMems.pdf

 Accroll = atan2(accy, accz)
 Accpitch = atan2( -accx, sqrt(accy^2 + accz^2) )

source:https://www.nxp.com/docs/en/application-note/AN3461.pdf

What is the correct way to find roll yaw pitch?


texts:
I installed the required drivers for the board. But I cannot still upload a program to the board. It says that

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.10.0_x86__mdqgnx93n4wtt\hardware\tools\avr/etc/avrdude.conf"

     Using Port                    : usb
     Using Programmer              : stk500v2

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

avrdude done.  Thank you.

An error occurred while uploading the sketch


texts:
Need a specific sensor that will detect when a pet comes close in a range of distance. As it comes close a beep intimates that the pet has reached. What sensor will work here. Can it work with an Arduino. ?
cat has a habit of going down 2 floors to poop. Problem is when she comes back the door is closed and neighbours don't like it. So a system by which moment she comes within a certain distance of a gadget it then beeps. May be a product already in market. Or if need be to put things together to work. Bell is a good idea but won't be loud.


texts: Transmit image file thougth the TX TR serial line

texts:
I have a digital camera with a USB port for image dowload from the camera SD card.

I will like to be able to capture this image files store in the camera SD card using the Arduino  TX TR lines (serial) then transmit this image file to the computer from the USB connection from Arduino to Computer.

The reason need this scenario responds to that the camera dissables the shutter when sensing a USB cable conneted to computer. I do not knwo why this happens but I suspect is an underdeveloped feature of the camera.

Basically, I will like to use Arduino as a USB hub for external devices but at the same time to power down the line when no longer need the device using the Arduino TX and TX line . This will give tha camera a sense that the camera is been unplugged.

simulate this circuit – Schematic created using CircuitLab


texts: How to use SD card, RFID reader and LCD together?

texts: I'm trying to use SD card reader, RC522 RFID reader, and ILI9225 in my project. When I initialize the SD card, RC522 stops working. However, Individually they both work fine without any problem. Could anyone please suggest any suggestions? Thanks in Advanced.


texts: Why my LCD does not work with this if statement?

texts:
#include <LiquidCrystal.h>
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);
int greenLedPin = 12;
int blueLedPin = 11;
int redLedPin = 8;
int yellowLEdPin = 9;

int lightSensorPin = A0;
int analogValue = 0;

void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  pinMode(greenLedPin, OUTPUT);
  pinMode(blueLedPin, OUTPUT);
  pinMode(redLedPin, OUTPUT);
  pinMode(yellowLEdPin, OUTPUT);
  Serial.begin(9600);
  while (! Serial);

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(analogRead(lightSensorPin));
  analogValue = analogRead(lightSensorPin);
  if (analogValue < 50) {

digitalWrite(redLedPin, HIGH);

  }
  else if (analogValue >= 50 && analogValue <= 99) {
    digitalWrite(yellowLEdPin, HIGH);
  }
  else if (analogValue >= 100 && analogValue <= 300) {

    digitalWrite(blueLedPin, HIGH);
    lcd.print("its bright");
 }
  else {
      digitalWrite(greenLedPin, HIGH);
      lcd.print("its bright");
      }

  delay(3000);
  digitalWrite(greenLedPin, LOW);
  digitalWrite(blueLedPin, LOW);
  digitalWrite(redLedPin, LOW);
  digitalWrite(yellowLEdPin, LOW);
  lcd.clear();

}

I'm very new to this so sorry if its a dumb mistake and I know my LCD is working right, since I have tested it so all the pins are good.


texts:
I am trying to make an arduino alarm clock to which you can send alarm clock times over the web.
This is the HTML code

 <input type="checkbox" name="alarm1" id="alarm1">1</button>

It's sending the HTTP correctly but the rest of the code insists that the alarms are always on.

      if (_server.arg("alarm1") = "on") {
      alarm1 = true;
      Serial.println("Alarm 1 is set");
  }
  else {
      alarm1 = false;
      Serial.println("Alarm 1 is inactive");
  }


texts:
i recently started using Arduino uno , but to my despair , the ground pin , without which i cant do any project (or can i ) , so i thought of a possible solution , what if i could program the board to make a pin act as a ground , so what to do
straight 2 questions , what to do to convert any pin into ground
or can i ignore using the provided ground pin .
i have already tried fixing the pin but it cant be fixed because a detached pin has got stuck into it


texts: Do I need a bubble sort or something easier?

texts:
I'm using an Arduino Leonardo and a GPSTiny++ library to parse NMEA strings from my GPS receiver. In this chunk of code I'm averaging all satellite SNR numbers for satellites which are locked (Being used for navigation). The avg value provides some general information on overall performance but I'm also really looking for the avg Top 4 values.

I believe I would need to do some sort of sorting algorithm. Increment through the top 4 and average those values.

Here's a snippet of my output window:
12/13 0.92 SNR=17 10 27 27 30 29 25 27 33 0 0 0 31 25.60 0.00

The second to last number is the average.

How do I get started?

int totalSNR = 0;
    float avgSNR = 0;
    int count = 0;
    Serial.print(F(" SNR="));
    for (int i = 0; i < MAX_SATELLITES; ++i)
      if (sats[i].active)
      {
        if (sats[i].snr > 0) {
          count++;
          totalSNR = totalSNR + sats[i].snr;
        }

        Serial.print(sats[i].snr);
        Serial.print(F(" "));
      }

    avgSNR = float(totalSNR) / float(count);
    Serial.print(avgSNR);


texts:
I am trying to read BME680 on ESP32-CAM with following code :

(Before trying BME680, I have suscessfully connected BME280 to ESP32-CAM over S/W SPI)

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include "Adafruit_BME680.h"

#define SEALEVELPRESSURE_HPA (1013.25)

#define BME_SCK 12 //Connected SCL to IO12
#define BME_MISO 15 //Connected SDO to IO15
#define BME_MOSI 13 //Connected SDA to IO13
#define BME_CS 14 //Connected CS to IO14

//Adafruit_BME280 bme; // I2C
Adafruit_BME680 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
//float temperature = 0;
//float humidity = 0;
//float pressure = 0;

void setup() {
  Serial.begin(115200);
  while (!Serial);
  Serial.println(F("BME680 test"));

  if (!bme.begin(0x76))
  {
    Serial.println("Could not find a valid BME680 sensor, check wiring!");
    while (1);
  }

  // Set up oversampling and filter initialization
  bme.setTemperatureOversampling(BME680_OS_8X);
  bme.setHumidityOversampling(BME680_OS_2X);
  bme.setPressureOversampling(BME680_OS_4X);
  bme.setIIRFilterSize(BME680_FILTER_SIZE_3);
  bme.setGasHeater(320, 150); // 320*C for 150 ms
}

void loop()
{
  if (! bme.performReading())
  {
    Serial.println("Failed to perform reading :(");
    return;
  }
  Serial.print("Temperature = ");
  Serial.print(bme.temperature);
  Serial.println(" *C");

  Serial.print("Pressure = ");
  Serial.print(bme.pressure / 100.0);
  Serial.println(" hPa");

  Serial.print("Humidity = ");
  Serial.print(bme.humidity);
  Serial.println(" %");

  Serial.print("Gas = ");
  Serial.print(bme.gas_resistance / 1000.0);
  Serial.println(" KOhms");

  Serial.print("Approx. Altitude = ");
  Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
  Serial.println(" m");

  Serial.println();
  delay(2000);
}

When I try to upload the code to ESP32-CAM while BME680 is connected I get following error

esptool.py v2.6
Serial port /dev/ttyUSB0
Connecting....
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
MAC: a4:cf:12:99:b5:70
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Warning: Could not auto-detect Flash size (FlashID=0xffffff, SizeID=0xff), defaulting to 4MB
Compressed 8192 bytes to 47...

A fatal error occurred: Timed out waiting for packet content
A fatal error occurred: Timed out waiting for packet content

Then I tried to disconnect BME680 and uploaded the code to ESP32-CAM which worked, then connected BME680 back to ESP32-CAM.

But now I see following error in Serial Monitor :

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jn  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot0x33 SPI_FAST_FLASH_BOT)
lash read err, 1000
et_main.c 371
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
flash read err, 1000
ets_main.c 371
ets Jun  8 2016 00:22:57

Any idea what is wrong here ?

Update :

I switched #define BME_SCK 12 to #define BME_SCK 16, now getting following message

ts Jun  8 2016 00:2:57

rst:0x1 (POWEON_REST),boot:0x13 (PI_FAT_FLASH_BOOT)
cnfigsi: 0, SPIWP:0xee
clk_dv:0x00,q_drv:0x0,d_drv0x00,cs0_drv:0x00,d_drv0x00,wp_drv:0x0
mod:DIO, clock div:
loa:0x3fff0018,len:4
load0x3fff001c,len:1216
ho 0 tail 12 room 4
lod:0x40078000,len:9720
h 0 tail 12 room 4
load0x40080400,len:6352
etry 0x400806b8
[D][esp32-hal-psram.c:47] psramInit(): PSRAM enabled


texts:
Forgive me for this really dumb question. I am an amateur in electronics, and im trying to wrap up my head around this question and im not able to do so. Need your help.

Im trying to power up a nodemcu using a 5v 1A power supply- I connected +ve to Vin and ground to ground. But i see that 5v is not enough to power up the nodemcu. So i removed the 5V and connected to a 9V battery, and again I find the same issue- the power is not enough. Knowing that i did something wrong - i measured the voltage across Vin and ground and find it to be around 2.5V when using the 5v source and around 2.5V when using the 9 V battery too.

Confused and thinking that my nodemcu is corrupted, i ordered a new one, and did the same. But i find that when i try to supply power using Vin, the voltage across the device- Vin and ground is around 2.5V for the newer device also. Obviously Im missing something.

Can anyone tell me what is it that Im doing wrong. Please tell me how to power a nodemcu without using a usb and only using a 5v source.


texts: Why does the LED state behave differently?

texts:
I wanted the sensor to be high when I press the button, but when DigitalRead does low, the LED turns on, when it does high, the LED goes off.
Whereas when the digitalRead is high, isn't it supposed to turn on the led?
int pirPin = 8;
int ledPin = 13;
int state;
unsigned long previousMillis = 0;        // will store last time LED was updated
const long interval = 1000;

void setup() {
  pinMode(pirPin, INPUT);
  pinMode(ledPin, OUTPUT);

}

void loop() {

  unsigned long currentMillis = millis();
  state = digitalRead(pirPin);
  Serial.println(durum);

  if (state == HIGH) {
    previousMillis = currentMillis;
     }
    if (currentMillis - previousMillis >= interval) {
      digitalWrite(ledPin, LOW);
    }
    else
      digitalWrite(ledPin, HIGH);
  }


texts:
I tried a simple blink for my fingerprint sensor which is GT-511C1R, but I have experienced of having an error.

  FPS_Blink.ino:12:26: fatal error: FPS_GT511C1R.h: No such file or directory
  compilation terminated.

I downloaded the whole library but still same error.


texts:
I'm testing the SN76489AN chip with Arduino and I'm able to play the 3 tones I want etc BUT I don't understand why the READY pin is not working? The datasheet says the pin goes high when the chip is ready and low when it's busy with processing a command. But the READY pin is always low! I've got 2 brand new pieces of the chip and they both act this way. I've even tried to pull-up this pin but it didn't help. I see everyone is just using delayMicroseconds in their examples, so I guess it is a common problem but it's just strange... Is it a bug in the chip or what? Does anyone know?

Thanks!


texts: how to use mouse.h library for arduino uno

texts:
I want to use mouse.h library with arduino but mouse.h library only for Leonardo not UNO . How to use mouse.h for UNO if not
can we convert arduino UNO to Leonardo ?


texts: Override #define statements in libraries

texts:
I'm using a library that, by default, wants to use Serial2 as the interface to a display, however, I'm working with an UNO which only has one serial interface, so the compile fails. I'm trying to use a SoftwareSerial instead, but I can't figure out how to override the #define statement in the library without editing the library.

I'm guessing since the software serial port isn't generated at compile time, I can't.

#include <SoftwareSerial.h>
#define nexSerial HMI
#include <Nextion.h>

SoftwareSerial HMI(8,9);

void setup() {
  // put your setup code here, to run once:

}

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

}

I haven't started writing code yet, can't get past the attempt to redirect the serial interface to a software serial.


texts: Looking for a sensor that measures heart/pulse rate

texts:
I am looking for a sensor which is able to measure heart/pulse rate. Apart from the common pulse sensor from here, are there any others?

I have seen people recommending this as well, and it seems more accurate. Should I get the piezo vibration sensor or are there better sensors? Hoping for something that is easy to use (Like the pulse sensor where you can just place your finger onto the sensor)

Cross-post from: https://www.reddit.com/r/arduino/comments/8f051k/looking_for_a_sensor_which_measures_heartpulse/ and https://forum.arduino.cc/index.php?topic=543857.0


texts: Can an RFDuino Implement a BLE Host for a BLE Sensor?

texts:
I would like to prototype a bridge from a Bluetooth sensor (client) to the cellular network, using an Arduino to control the communication between the Bluetooth sensor and the internet, via the cellular network.

I find much written about apps on one's mobile to connect to the BLE devices, however not the other way around.

Is it possible to use something like an RFDuino to implement the BLE host, to which the BLE sensor would pair - and then have the RFDuino push data out a cellular device, like the FONA from Adafruit?

UPDATE: I've since read that apparently the Bluetooth protocols allow masters and clients to switch roles dynamically - which would lead me to believe that I can program a BLE device as either master or client.

I also looked at a BlueGiga device, which specified it could run as Master or Client.

Not sure if the hardware needs to support the different modes.


texts: Measure current across shunt resistor (Power Analysis)

texts:
I am trying to reproduce the side-channel power analysis attack described in this paper: https://pdfs.semanticscholar.org/7946/a8ee82658e2ffb017270331f220a55f5ace6.pdf for educational purposes.

The attack (on the HCS3xx family of chips) requires measuring the power consumption (i.e. current) that the chip is using in order to reveal its cryptographic key.

In the paper, they describe their setup as attaching a shunt resistor in the ground path and using a digital oscilloscope (with a sampling rate greater than 1MHz) to measure the voltage drop across this resistor.

I have reproduced this setup to the best of my abilities (pictured in the schematic below), but the problem is I don't have an oscilloscope.

simulate this circuit – Schematic created using CircuitLab

Therefore, I've decided to use an Arduino Uno I have lying around as a poor man's oscilloscope.

Besides the fact that the Arduino ADC has a much lower sampling rate (~77KHz vs. the ideal 20MHz described in the paper), I have been having an issue getting a reliable voltage reading across the shunt.

While trying to use the full 10-bit ADC, and producing samples as (ADCH << 8) | ADCL in my ADC ISR, I do not get any samples that are greater than 0.

However, when I left-align the ADC to only use 8-bit precision (with ADMUX |= 1 << ADLAR and read with just ADCH, I get non-zero values but none with a value greater than one.

Could it be that the amount of power that the chip consumes is so small that the Arduino does not have enough precision to read it? Or could it be that my shunt has too large of a resistance and is causing a reduced current throughout the circuit?


texts: Reading states of multiple toggle switches

texts:
I'm working on modifying this example from the Arduino website to read the state of 3 toggle (SPDT) switches. If I have one toggle switch hooked up, my sketch works as expected...the sketch will log the state of the switch in the serial debugger every-time the state changes, and only when the state changes.

However, if I add in two more switches, the serial debugger will continuously output my log messages, without detecting if the state has changed.

Here's the code from my sketch:

const int  switchOnePin = 2;    // digital in 2 (pin the switch one is attached to)
const int  switchTwoPin = 3;    // digital in 3 (pin the switch two is attached to)
const int  switchThreePin = 4;  // digital in 4 (pin the switch three is attached to)

int switchOneState = 0;         // current state of the switch
int lastSwitchOneState = 0;     // previous state of the switch

int switchTwoState = 0;
int lastSwitchTwoState = 0;

int switchThreeState = 0;
int lastSwitchThreeState = 0;

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);

  int switchOneState = 0;         // current state of the switch
  int lastSwitchOneState = 0;     // previous state of the switch switch pins as an input
  pinMode(switchOnePin, INPUT);
  pinMode(switchTwoPin, INPUT);
  pinMode(switchThreePin, INPUT);
}

void loop() {

  // read the switch input pins:
  switchOneState   = digitalRead(switchOnePin);
  delay(50);
  switchTwoState   = digitalRead(switchTwoPin);
  delay(50);
  switchThreeState = digitalRead(switchThreePin);

  // compare the switchState to its previous state
  if (switchOneState != lastSwitchOneState) {
  // if the state has changed, increment the counter
    if (switchOneState == HIGH) {
    // if the current state is HIGH then the button
    // went from off to on:
    Serial.println("Switch one is on");
  }
  else {
    // if the current state is LOW then the button
    // went from on to off:
    Serial.println("Switch one is off");
  }

  if (switchTwoState != lastSwitchTwoState) {
    if (switchTwoState == HIGH) {
    Serial.println("Switch two is on");
  }
  else {
    Serial.println("Switch two is off");
  }

  if (switchThreeState != lastSwitchThreeState) {
    if (switchThreeState == HIGH) {
    Serial.println("Switch three is on");
  }
  else {
    Serial.println("Switch thre is off");
  }
 }
}
  // Delay a little bit to avoid bouncing
  delay(50);
}
// save the current state as the last state,
//for next time through the loop
lastSwitchOneState   = switchOnePin;
lastSwitchTwoState   = switchTwoPin;
lastSwitchThreeState = switchThreePin;
}

And here's what my circuit looks like:

Does anyone have any insight into what I may be doing wrong? I'm not quite sure if it's a circuit or a sketch issue (or both).

EDIT I tried adding a delay of 50ms between each digital input read, but that still did not seem to help the problem.


texts: Uploading bootloader on ATmega328P SMT package using Arduino Uno

texts:
I have been trying to upload bootloader on ATmega328P SMT package on a custom PCB using Arduino Uno as ISP, I was quite successful.

I have Googled a lot and have tried numerous ways, sometimes I was able to successfully upload the bootloader, but I am not able to upload the sketch am getting "avr sync error".

What kind of bootloader should I use for this particular package?
How should I upload the sketches into the chip?


texts:
I am currently following this tutorial on building a Simple Audio Player for the Arduino. I was about to finish the circuit only to realize that the required board is an Arduino Due and I have the Uno.

Because the Uno does not have its own DAC port, I was wondering what other options are available for me to accomplish the same thing while keeping the circuit as similar to the one listed in the tutorial.

Thanks


texts:
As far as I understand it checks for a valid serial connection (new program incoming) and then either writes it to flash or starts executing the existing program.

Can't the 32u4 or EDBG fill the role of an ISP and program the MCU instead of the MCU self-programming? I know the EDBG is accessed via OpenOCD to write the bootloader to the SAMD21 on Arduino Zero boards so why is the bootloader even required?


texts: Servo motors not working when called upon using I2C

texts:
So I'm using this movement() function inside the slave Arduino Uno, which basically handles two stepper motors and one servo motor. When I call this function through the Serial.read() of the Arduino Uno, it works perfectly, both the steppers and the servo.

I have a master Arduino Mega interfaced with the Uno (mentioned above) when I send a wire message from the Mega to Arduino to run the movement() function in the Uno, the steppers work fine, but the servo does not work. Although, again I mention that when the function is called upon using the Serial.read() of the Uno, it works absolutely fine.

I'm using an Adafruit motor shield on the Arduino Uno as well.

OK so this is the Uno (slave code)

void setup() {
  servo1.attach(9);
  Serial.begin(9600);
  Wire.begin(5);
  Wire.onReceive(receiveEvent);
  Serial.begin(9600);
}

void loop() {
  //other stuff
}

void receiveEvent(int howMany) {
  while(Wire.available()) {
    char c = Wire.read();
    int From = Wire.read();
    int To = Wire.read();
    int x = 0;
    movement(From,To);
  }
}

int movement(int from,int to) {
  int X_From = from / 10;
  int X_To = to/10;
  int Y_From = from % 10;
  int Y_To = to % 10;
  /* First we have to get the motor position and move the motor to the from position */
  /* === START === */
  int diff_X = X_From - motor_X;
  int diff_Y = Y_From - motor_Y;
  int Y_Value = abs(diff_Y * Y_Steps);
  servoDown();
  if(diff_X != 0) {
    if(diff_X > 0) {
      /* Positive value means the X_Axis motor will move in the forward direction */
      int X_Value = abs(diff_X * X_Steps);
      X_Forward(X_Value);
    } else if(diff_X < 0) {
      /* Negative value means the X_Axis motor will move in the backward direction */
      int X_Value = abs(diff_X * 400);
      X_Backwards(X_Value);
    }
  }
  if(diff_Y != 0) {
    if(diff_Y > 0) {
      Y_Forward(Y_Value);
    } else if(diff_Y < 0) {
      Y_Backwards(Y_Value);
    }
  }
  Serial.println("Motor movement done");
  /* === END === */
  motor_X = X_From;
  motor_Y = Y_From;
  int diff_X_2 = X_To - motor_X;
  int diff_Y_2 = Y_To - motor_Y;
  int Y_Value2 = abs(diff_Y_2 * Y_Steps);
  servoUp();
  if(diff_X_2 != 0) {
    if(diff_X_2 > 0) {
      /* Positive value means the X_Axis motor will move in the forward direction */
      int X_Value2 = abs(diff_X_2 * X_Steps);
      X_Forward(X_Value2);
    } else if(diff_X_2 < 0) {
      /* Negative value means the X_Axis motor will move in the backward direction */
      int X_Value2 = abs(diff_X_2 * 400);
      X_Backwards(X_Value2);
    }
  }
  if(diff_Y_2 != 0) {
    if(diff_Y_2 > 0) {
      Y_Forward(Y_Value2);
    } else if(diff_Y_2 < 0) {
      Y_Backwards(Y_Value2);
    }
  }
  motor_X = X_To;
  motor_Y = Y_To;
  Serial.println("piece movement done");
  return 1;
}

void servoUp() {
  for (i = 100; i >= 0; i--) {
    servo1.write(i);
  }
}

void servoDown() {
  for (i = 0; i < 100; i++) {
    servo1.write(i);
  }
}

This is the master Mega Code:

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

void loop() {
  //check if a condition appeared from sensor and then send the data to Uno to run the movement function through sendData()
  sendData(From,To);
}

void sendData(int From,int To) {
  Wire.beginTransmission(5);
  Wire.write('f');
  Wire.write(From);
  Wire.write(To);
  Wire.endTransmission();
}

Any suggestions what's wrong?


texts: Arduino encrypted wireless communication

texts:
Is there any way or library to communicate two Arduino devices  with encrypted connection using modules NRF24L01 or "433Mhz RF" ?
Similar encryption like CCMP in Wi-Fi network.


texts: Arduino clone avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x04

texts:
Hi firstly sorry for my english. I am using windows 10, IDE version 1.8.13. I sure for selected correct arduino(Arduino uno),port is correct, tried another cable. I uploaded sketch 3-5 times but after give this error. I using MAX7219 led matrix shield and shield is working and shown my lastest upload before error. Error:
avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x04
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x04
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x04
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x04
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x04
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00


texts:
I have an Android app that sends data to the arduino HC-06. It is however giving me colors i did not send to it. Eg. Red in place of green, white in place of red etc.
Here is a snippet of my android code that sends the data via bluetooth

 public void onColorChanged(int color) {
    BluetoothV2 bluetooth = new BluetoothV2();
    int r,g,b;
    r = Color.red(color);
    g = Color.green(color);
    b = Color.blue(color);
    bluetooth.Message(r+","+g+","+b);
 }

Here is a snippet of my arduino code

void loop() {

if(Serial.available()>0){

while(Serial.available()>0){
   char inChar = (char)Serial.read();
   inputString += inChar;
}
   int red = Serial.parseInt();
   int green = Serial.parseInt();
   int blue = Serial.parseInt();
   color(red,green,blue);
   inputString = "";
   Serial.println("R:"&& red &&"G:"&& green &&"B:"&& blue);
  }
}

void color (unsigned char red, unsigned char green, unsigned char blue){
   analogWrite(redPin, 255-red);
   analogWrite(greenPin, 255-green);
   analogWrite(bluePin, 255-blue);
}

Terminal data

               2,,,,,,,,,,,,,2,,5,,,,,,,,,,,,,,,,,,,,,,,,,02725,1,502725,,,,,,,,,02514,5,602515     ,5,3,,,,,025

Is the problem how i get the data though Serial.read()? Or what am i missing


texts:
I am currently Working on a project, where I save values in a JSON File on an SD Card.

The JSON looks something like this:

{ "ID1":{[[starttime, endtime],
          [starttime, endtime],
          [...]],
  "ID2":{[[starttime, endtime],
          [starttime, endtime],
          [starttime, endtime],
          ...],
...
}

I have to add start and endtimes to IDs, so I have to edit the file.
Is there a nicer/easier/better way than the following?:

Create Buffer (e.g. 512 Bytes)
Read 512 Bytes from file to buffer
Edit/Add Values in Buffer
Save Buffer to another File
Repeat 2. to 4. until end of file
Remove old File and rename new File

I am currently using the ESP32 Core SD.h Libary


texts:
I have switch is a line connected to Digital pins 1,2,3,4,5 . When pins 1 connects, I need a timer to start. as the rest connect i need it to mark the time in the console output of each one and End on the timer on connection to pin 5. ex

START:
0.00
1.43
2.12
2.94
3.89
END

Also is there a way to Save the data to a log (.txt or whatever) If not its fine but I need to record results.

(This is for a school project)
THANKS!


texts: Error on Arduino Code (unknown type name 'LiquidCrystal')

texts:
I am using Arduino IDE 1.6.8 and I am trying to compile the following code Wheatstone Bridge. I have currently a really weird error:

unknown type name 'LiquidCrystal'

This error seems to come from the header file:

// Include the Wheatstone library
#include <WheatstoneBridge.h>

// Include the LCD library
#include <LiquidCrystal.h>

// Declare external global lcd
extern LiquidCrystal lcd; <<<Error

I have already installed the LiquidCrystal library but I don't know if this trouble is due to the compiler (and the IDE) or something is wrong. The compiler seems to find the right libraries...


texts: the arduino software is looking for spi.h in a example code

texts:
I'm having a problem in compiling the example ScanNetwork codes in arduino it brings up an error that states "SPI.h: No such file or directory." Now I added an SPI folder in the libraries but after verifying it shows another error. I did the same thing to others but the compiler is looking for more and more files. What can I do?
By the way, I'm using a Gizduino+ w/ ATmega644.


texts: Remove blocking delay() toneMelody function?

texts:
I would like to change the delay() into a nonblocking function in the code below. I've implemented it (a part of a tutorial from arduino.cc) in my code, but the delay() is blocking the rest of my code. Can anyone help me to change this?

void speelMelodie(int melodie){

if(melodie == 1){

      for (int thisNote = 0; thisNote < 8; thisNote++) {

      int noteDuration = 1000 / noteDurations1[thisNote];
      tone(speaker, melody1[thisNote], noteDuration);

      int pauseBetweenNotes = noteDuration * 1.30;
      delay(pauseBetweenNotes); // <-- this one has to be changed

      noTone(speaker);
      }
  }

else if (melodie == 2) {
      // the same part as previous part (for loop)
  }

else if (melodie == 3) {
      // the same part as previous part (for loop)
  }
}


texts:
I've tried searching for this issue but came up empty. Due to the desire to use a better IDE, I installed Sublime Text 3 and Stino. I have installed the Stino package and now have the Arduino menu inside the Sublime Text editor. I have selected the Arduino application folder appropriately. However, when I compile the simple Blink example, I'm presented with the following error. This error comes up when I attempt to compile any Arduino project. Have I forgotten to configure a setting? All videos and tutorials I've seen just follow the same steps as I have and don't seem to include any additional configuration (besides selecting the Arduino application folder).

[Stino - Start building "Blink"...]
[  3%] Creating C:\Users\cketc_000\Documents\Arduino\Blink\Blink.ino.cpp.o...
"C:\Program Files (x86)\Arduino/hardware/tools/avr/bin/avr-g++" -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD  -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=161 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\examples\01.Basics\Blink" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\standard" "C:\Users\cketc_000\Documents\Arduino\Blink\Blink.ino.cpp" -o "C:\Users\cketc_000\Documents\Arduino\Blink\Blink.ino.cpp.o"
The filename, directory name, or volume label syntax is incorrect.

[Stino - Exit with error code 1.]


texts:
I am planning to connect multiple Arduinos to my Raspberry Pi. There are basically two ways I can achieve that:

Use an USB hub. Each Arduino will then be available through ordinary serial commands both for reading and writing. The USB hub I have is powered and can handle both communications and powering the Arduinos.
Use I2C, so that the Arduinos are I2C slaves of the Raspberry Pi.

Since USB is used for updating the Arduino, I don't have the best feeling about using this same connection for "management" tasks.

Are there any known disadvantages to using the pre built USB socket on
the Arduino in "production", any best practises or similar saying that I should not do
this? Is this USB socket meant to be used for debugging and code deployment only?

The plan is to let the computer send commands to the Arduinos using a serial protocol. The computer will automatically detect whenever an Arduino is connected and immediately send a "hello" command over serial. The Arduino is then supposed to send back its "name" and a list of capability keywords. A capability may be "motion-sensor". The computer will then know that it can ask the Arduino if it has detected motion. Other capabilities may be "temperature-sensor", "barometric-sensor", "lights".

It's for a generic open source home automation system/robotics system I am working on creating a framework for.


texts:
I'm newbie about Arduino.
Can i build arduino robot wheels using Canon/Epson Cartridge inkjet printer?

The idea is like Drawing Robot

but i want to use cartridge printer instead of using a pen.

so after searching, and it look like ZUtAPocketPrinter

The Drawing Robot is using Trinket Pro
And ZUtAPocketPrinter is using Arduino (don't know using Uno/Nano/etc)

Can I use Trinket Pro or what types of arduino that i can use (Uno, Nano)?

And what hardware, sensor that require to scan/measure size of the paper?

And if there is tutorial, please share the link.


texts:
The project is to make a 4WD car using arduino uno(clone) and four toy dc motors. I am using a adafruit motor shield v1.2(clone). The car is required to run autonomously, please suggest batteries for the arduino and the shield.
Also when I am using external power connector for arduino, all the motors start at different timing.


texts: Error: function was not declared in this scope when using a library without classes

texts:
I have created a library of functions that doesn't have and mustn't have a class. In order to have functions inside the library that can only be called from the library itself, you just write them into the .cpp file and leave them out of the header file completely. Here is the .cpp file of the library (the header file is empty):

#include "Lib.h"

// Definition of foo1
static void foo1(){
    foo2();
}

// Definition of foo2
static void foo2() {}

When including the library in an empty sketch and compiling it I get the following error message:

  error: 'foo2' was not declared in this scope

What is the problem here?


texts:
I receive byte data from a RS-232 device with Serial.read();. Now I need to slice this down in bit-pieces:

value1: 15bits
value2: 7bits
value3: 9bits
value4: 12bits
and so on

Data from the stream (switch them around for better understanding):

Byte 1: 00101100 => 00110100 (least significant byte first)
Byte 2: 10011011 => 11011001
Byte 3: 00110011 => 11001100
Byte 4: 11101000 => 00010111
Byte 5: 01001100 => 00110010
Byte 6: 01100111 => 11100110

Now the least significant is first.

value1: 00110100.1101100[1] => 6956
Need to cut of the last bit of the second byte
value2: 1.110011[00] => 103
Add the last bit of the second byte and cut off the last two bits of the third byte
value3: 00.0001011[1] => 416
Add the last two bits of the third byte and cut off the last bit of the fourth byte
value4: 1.00110010.111[00110] => 3737
Add the last bit of the fourth byte and cut off the last 5 bits of the fifth byte

Now the question: How do I realize this from programming side. I'm lost.


texts:
I know that for the Arduino (and C in general) that for comparison sake, "false" is 0, while any non-zero integer is "true". The question that I have is does the bool data type "return" a concrete integer for "true" or "false"?

When I tried Serial.print(true == 1), it printed 1 (which I assumed to be "true"), but when I tried Serial.print(true == 2), it printed 0 (which I assumed to be "false"). When I tried Serial.print(false == 1), it printed 0 and Serial.print(false == 0) printed a 1.

I didn't know if "true" always evaluated to 1 and "false" always evaluated to 0, or if this is not supposed to happen.


texts:
I have a bluetooth adapter connected to uno, and using a serial monitor on phone.

In the arduino code im debugging there is this line waiting for new line signal in the serial stream:

char c = SerialBT.read();

if (c == '\r' || c == '\n'){

no matter what i try sending to via my phone i cant get this to evaluate as true...

if i send \n , i believe it is sending it as 2 chars \ and n , not as a single char.

is this a problem with the phone app or what ?