texts: Arduino WiFIWebSever - why client.println()?

texts:
I need to modify the WiFiWebServer example on the Arduino website but I am having some trouble understanding the code. I am hoping to get some advice from the community on the client-server relationship in this example so I can better modify it to suit my needs.

The problem I am having is the jump between server commands and client commands. Initially I see server commands; server.begin() in setup and server.available() in the loop. The commands quickly shift, however, as nearly all the other commands in the loop become client.println()'s.

I understand the initial client commands that deal with whether the client is available and whether it is still connected. The part I don't understand, however, are the client.read and client.println commands. Even client.read makes some sense to me since I want some communication from the client side but why does the example use client.print? The Arduino webpage defines the WiFiClientPrintln as data you write from the client to the server that it is connected to. Wouldn't I want to use server.print since the Arduino in this example is the server and the client is the computer I use to view the webpage that I built on the server?

I am using the WiFIWebServer example as a template for my project. The goal is to have the Arduino take sensor readings and post them on a webpage it hosts by acting on the server. This is quite similar to the example but I notice that I have slow update/transmission speeds and errors when a different client connects to the server. For example, if I view the website on my computer, I get the data fairly consistently If somewhat slow. If I try to view the same website off my mobile device, however, I have problems connecting, may need to refresh several times and the webpage crashes on the computer.

I am trying to troubleshoot the issue but going through the code I can't figure out the reason for the client.println()'s instead of server.println(). Even if that isn't the cause of my multi-client issue, I would like a better understanding of the code before going forward so would appreciate any guidance you can provide.


texts: Osepp DS1307 RTC program error (tmElements_t tm; does not name a type)

texts:
Using a basic 1307 SetTime program, and ran into a problem (first time programming a module).

#include <Wire.h>
#include <Time.h>
#include <DS1307RTC.h>

const char *monthName[12] = {
  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
};

tmElements_t tm;

void setup() {
  bool parse=false;
  bool config=false;

  // get the date and time the compiler was run
  if (getDate(__DATE__) && getTime(__TIME__)) {
    parse = true;
    // and configure the RTC with this info
    if (RTC.write(tm)) {
      config = true;
    }
  }

  Serial.begin(9600);
  while (!Serial) ; // wait for Arduino Serial Monitor
  delay(200);
  if (parse && config) {
    Serial.print("DS1307 configured Time=");
    Serial.print(__TIME__);
    Serial.print(", Date=");
    Serial.println(__DATE__);
  } else if (parse) {
    Serial.println("DS1307 Communication Error :-{");
    Serial.println("Please check your circuitry");
  } else {
    Serial.print("Could not parse info from the compiler, Time=\"");
    Serial.print(__TIME__);
    Serial.print("\", Date=\"");
    Serial.print(__DATE__);
    Serial.println("\"");
  }
}

void loop() {
}

bool getTime(const char *str)
{
  int Hour, Min, Sec;

  if (sscanf(str, "%d:%d:%d", &Hour, &Min, &Sec) != 3) return false;
  tm.Hour = Hour;
  tm.Minute = Min;
  tm.Second = Sec;
  return true;
}

bool getDate(const char *str)
{
  char Month[12];
  int Day, Year;
  uint8_t monthIndex;

  if (sscanf(str, "%s %d %d", Month, &Day, &Year) != 3) return false;
  for (monthIndex = 0; monthIndex < 12; monthIndex++) {
    if (strcmp(Month, monthName[monthIndex]) == 0) break;
  }
  if (monthIndex >= 12) return false;
  tm.Day = Day;
  tm.Month = monthIndex + 1;
  tm.Year = CalendarYrToTm(Year);
  return true;
}

And I got the following

"tmElements_t tm;" does not name a type.


texts: error 33 = got packets out of order arduino

texts:
my code was working and the connection with database was fine , until I don't know what happen every time I run my code it show this error , can please someone tell me what error 33 = got packets out of order means .
I'm using Arduino Uno


texts:
I have a master and a slave (both are arduino UNO) connected through SPI connected. I want to transmit a character to the slave and receive true or false to the master. The transmission is working perfectly. If I send '2', slave is receiving '2'. When I try to transmit an integer from slave to master, the master is always receiving some arbitrary number like 128 or 255.

Master Code:

void setup() {
  Serial.begin(9600);
  Serial.println("Master");
  digitalWrite(SS,HIGH);
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV8);
}
void loop() {
  digitalWrite(SS,LOW);  //  Slave select to low
  received1 = SPI.transfer(test);  // test is a variable which is '2'. The data received by master is stored in received1 variable which is char.
  Serial.println(received1);
  digitalWrite(SS,HIGH);
}

Slave code:

void setup() {
  Serial.begin(9600);
  Serial.println("Slave");
  pinMode(MISO,OUTPUT);
  SPCR |= _BV(SPE);
  process = false;
  SPI.attachInterrupt();
}
ISR(SPI_STC_vect){
  received = SPDR;  // the data received by slave is slored in **received** variable(the variable is char type)
  Serial.println(received);
  process = true;
}
void loop() {
  if(process){
    SPDR = jj;  // Updating SPDR to send data from slave. jj is char type
    process = false;
  }
}


texts: Previous and updated releases of Arduino IDE are not be able to start on Win 8.1 x64

texts:
I have tried to install many versions of IDE, but non of them has started successfully. There is just the logo of the program shows up and then nothing happens.
My laptop: Toshiba Satellite C50-A630
The releases I have installed: 1.6.12 , 1.6.13, 1.0.6


texts:
I'm working on a project using steper motor which turn a threaded shaft (long screw) in order to open or close a water valve (high flow, high pressure).

My fear is that, after a long time of use, the grease on the threaded shaft will dissapear and it can became hard for the stepper motor to rotate correctly the threaded shaft.

In order to tell the user to add grease, I have to know when the stepper needs more effort than before to rotate the threaded shaft. So, would it be possible to detect the "effort" made by the stepper in order to get this information on the Arduino?

Any ideas are welcomed!


texts: Silly question but how would a circuit be set up with Arduino where two different resistors are in series but one has an unknown value (i.e. is just a piece of metal for example) and so how would we be able to find the current through each, collage through each and thus find the value of the resistance of the unknown wire.


texts: 1st LED turn ON when 1st button is pressed and other LEDs remaining OFF

texts:
I have 2 LEDs and 2 buttons. What I want to code is when first button pressed the 1st LED turn on (stay on for 5 seconds) and 2nd LED remain off, and same if 2nd button pressed the 2nd LED turn on and 1st LED remain off. I want the processing reset after 5 seconds.
Here is my work, what it does now is 1st LED turn on when I press 1st button, but the 2nd button and 2nd LED still can press and light up right after. I want the 2nd button deactivate when 1st button pressed for 5 seconds.
Please give me basic program because I am new to this.

int pinButton_1 = 8; //the pin where we connect the button
int pinButton_2 = 9;
int LED_1 = 1; //the pin we connect the LED
int LED_2 = 2;
void setup() {
  pinMode(pinButton_1, INPUT); //set the button pin as INPUT
  pinMode(pinButton_2, INPUT);
  pinMode(LED_1, OUTPUT); //set the LED pin as OUTPUT
  pinMode(LED_2, OUTPUT);
}

void loop() {
  int stateButton_1 = digitalRead(pinButton_1); //read the state of the button
  int stateButton_2 = digitalRead(pinButton_2); //read the state of the button
  if(stateButton_1 == 1) { //if is pressed
     digitalWrite(LED_1, HIGH); //LED_1 on
     digitalWrite(LED_2, LOW); //LED_2 off
     delay(50);
  }
     if (stateButton_2 == 1) {
      digitalWrite(LED_1, LOW);
      digitalWrite(LED_2, HIGH);
      delay(50);
     }
  }


texts:
I've put together this script that should allow my Arduino Mega to be show thermocouple readings on the serial monitor, whilst also showing readings of voltage and ohms across a given component. I'd be grateful for any advice on how it can be improved/streamlined:

#include <SparkFun_MCP9600.h>
MCP9600 tempSensor;
int analogPin = 0;
int raw = 0;
int Vin = 5;
float Vout = 0;
float R1 = 220;
float R2 = 0;
float buffer = 0;
float volt = 0;
int input = 0;

void setup() {
  Serial.begin(115200);
  Wire.begin();
  Wire.setClock(100000);
  tempSensor.begin();

  if (tempSensor.isConnected()) {
    Serial.println("Device will acknowledge!");
  }
  else {
    Serial.println("Device did not acknowledge! Freezing.");
    while (1); //hang forever
  }

  if (tempSensor.checkDeviceID()) {
    Serial.println("Device ID is correct!");
  }
  else {
    Serial.println("Device ID is not correct! Freezing.");
    while (1);
  }

  pinMode(A4, INPUT);
}

void loop() {

  input = analogRead(A4); //analogRead function is used to receive analog data
  volt = (input * 5.0) / 1024.0; //formula using for perform action

  if (tempSensor.available()) {
    Serial.print("Thermocouple: ");
    Serial.print(tempSensor.getThermocoupleTemp());
    Serial.print(" °C   Ambient: ");
    Serial.print(tempSensor.getAmbientTemp());
    Serial.print(" °C   Temperature Delta: ");
    Serial.print(tempSensor.getTempDelta());
    Serial.print(" °C");
    Serial.println();
  }

  raw = analogRead(analogPin);
  if (raw)
  {
    buffer = raw * Vin;
    Vout = (buffer) / 1024.0;
    buffer = (Vin / Vout) - 1;
    R2 = R1 * buffer;
    Serial.print("Vout: ");
    Serial.println(Vout);
    Serial.print("R2: ");
    Serial.println(R2);
    Serial.print("voltage is:");
    Serial.println(volt);
    Serial.print("current is:");
    Serial.println(volt / R2);
    delay(1000);
  }
}


texts: Connecting a Long Stem Thermometer to an Arduino to automate the recording of temperature in an experiment

texts: Is there a way to connect and read the output of a long stem thermometer like this one to an Arduino?


texts: Linking the Arduino Bootloader In Atmel Studio

texts:
I have been trying to get the Arduino bootloader to compile into my firmware binary in Atmel Studio. I got the bootloader project to link and compile. I use ArduinoCore and the bootloader as a dependencies to my main code. The dependency tree looks like:

ArduinoCore
bootloader
Main firmware

The Bootloader
It took me a bit to get the bootloader to accept the rest of ArduinoCore as a dependency but it compiles into a static library. I use the bootloader linker to specify the memory location of the bootloader binary. It should start at 0x0 and provide a jump to the main firmware, located at 0x2000.
Bootloader linker flags:
-Tbootloader_samd21x18.ld -Wl

And here are the contents of the linker script:
  FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x2000 /* First 8KB used by bootloader */
  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000-0x0004 /* 4 bytes used by bootloader to keep data between resets */

This is based off of the .cProj file that comes with the linker. It is compiled as a static library so I can include it into my final binary.
Main Firmware
My code has both the ArduinoCore and the bootloader static libraries as dependencies:
libm
libArduinoCore
libbootloader

And I am using these linker flags:
-Tflash_with_bootloader.ld -Wl,--cref -Os -Wl,--check-sections -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align

The contents of this linker script are moved out by 8KB in order to accommodate the bootloader at the start of the binary:
    FLASH (rx) : ORIGIN = 0x00000000+0x2000, LENGTH = 0x00040000-0x2000  /* First 8KB used by bootloader */
    RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000

And yet, my entry point does not appear to ever hit the bootloader. It jumps straight to "main.cpp" from ArduinoCore. The firmware runs as expected, but the bootloader does not appear to have been included.
Is this some kind of dependency issue? Am I misusing the linkers?
Any help with getting this to compile under a single binary would be very much appreciated. Thank you very much!


texts:
I want to shine LED in 64 of 255 duty cycles = level of brightness but it pops up this error (see picture). Can anybody tell me why and help me ? Thank you.
void setup() {
  // put your setup code here, to run once:

}

void loop() {

  analogWrite(11, 64)
  delay{1000};
  analogWrite(11, 0)
  delay(1000);

  // put your main code here, to run repeatedly:

}


texts: How to measure direction the car is coming to garage door?

texts:
my garage door is pretty narrow, about 10 cm (4") on each side of my car's rear mirrors. So every time I drive to garage, I need to go very slowly because I am afraid I might not be lined up correctly.

I am thinking about using Arduino and some sensors to help me. Output is pretty simple, just two leds, one for each side, showing me if I should turn little right or left to have perfect lineup to center. This I can handle with no problem

What I am asking for is idea how to measure the alignment of my car. I know how to use ultrasonic sensors for measuring distance. But I am not sure they are suitable for this project, because I want preferably to put arduino and sensors in my garage, not in my car.

Any idea how to work this out ?


texts: 5v relay module and suitable bulb adapter

texts: I have 5v relay module . I want to use it to connect e27 bulb adapter but i cant choose any suitable adapter . Pls help me sir. I to find exactly the same as the picture


texts: Serial1.readString() on arduino mega returns an empty string

texts: i have been trying to read text message from a sim module over serial1 of arduino mega, when i use the code msg = Serial1.readString(); the readString return an empty string i dont know if this is a problem with Serial1 or the readString() function. whenever i use the serialpassthrough that uses Serial1.read() the text message comes in complete but readString() dont work


texts: Running out of GPIO & looking for suggestions

texts:
I'm working on a project using a NodeMCU and am quickly running out of GPIO pins. I'm trying to decide which way to go to complete it.

Right now, I have the MCU connected to a MAX31856 PT100 thermocouple (SPI), a PWM output, a transistor (acting as a switch), a single button and a single LED. I'm needing to add at least 2 more of the MAX31856, a display (either I2C or SPI) and a rotary encoder/button.

I've looked into GPIO expanders, but I'm doubtful that the available libraries for the additional hardware will work through the expanders. I have a Mega that will work without a doubt, but then I will have issues with WiFi & MQTT. I looked at the Mega's with onboard WiFi, but I got so confused in reading how to program it, setting the DIP switches, etc that it doesn't seem like a valid choice.

Can anyone offer guidance?


texts: SeeedDuino/Grove and the story of not being able to upload programs

texts:
I am new to the arduino world and wanted to start playing with the micro controllers, I am a .NET developer by trade so not completely new to this kind of world.

I purchased a seeedduino v3 and a Grove started kit (No soldering skills here) and can't even get the basics to work.

I am setting up a simple button to light up the LED program. I have had it run once or twice but it seems really hit or miss on whether or not the Arduino IDE actually gets the program onto the seeedduino.

Arduino IDE (1.5.6-r2) set-up:
Followed setup instructions found here: SeeedDuino v3

Board: Arduino Duemilanove or Diecimila
Processor: ATmega328
Port: COM4 [this is what popped up once device was plugged in]
Button is installed on D3
LED is installed on D7

Program:

int button = 3;
int LED = 7;

void setup()
{
  pinMode(button, INPUT); //define button on INPUT devices
  pinMode(LED, OUTPUT);   //define LED on OUTPUT device
}

void loop()
{
  int buttonState = digitalRead(button); //read the status of hte button

  if(buttonState == HIGH) //also used (buttonState == 1)
  {
    digitalWrite(LED, HIGH); //also used digitalWrite(LED, 1)
  }
  else
  {
    digitalWrite(LED, LOW); //also used digitalWrite(LED, 0)
  }
}

Upload Verbose Message:

avrdude: verifying ...
avrdude: 1070 bytes of flash verified
avrdude: Send: Q [51]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]

avrdude done.  Thank you.

I have only had the LED from this program turn on twice, then reloading it ruins it.

SIDE NOTE

If I try and run Burn BootLoader I get this message-

avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

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

         Using Port                    : usb
         Using Programmer              : stk500v2
avrdude: usbdev_open(): did not find any USB device "usb"


texts: Arduino Leonardo - Setting up bluetooth - AT command from terminal does not return anything

texts:
I am trying to setup bluetooth with a board that contains Arduino Leonardo chip.
My full setup is:
The main board: https://www.dfrobot.com/product-1148.html
The base shield: https://coolcomponents.co.uk/products/grove-base-shield-for-arduino-v2
The bluetooth module: https://wiki.seeedstudio.com/Grove-Serial_Bluetooth_v3.0/
The bluetooth module is connected to D8 port of the base shield.
The reason is "not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI)." as explained here: https://www.arduino.cc/en/Reference/SoftwareSerial
Here is the full code.
#include <SoftwareSerial.h>   //Software Serial Port

/*Connect your Bluetooth Module to D8 otherwise it will not work due to Arduino Leonardo */

#define RxD         8
#define TxD         9

SoftwareSerial blue(RxD,TxD);

void setup()
{
    Serial.begin(9600);
    blue.begin(9600); //anything other than 9600 will not work

    // wait for serial port to connect. Needed for native USB
    while(!Serial){
    ;
    }

    pinMode(RxD, INPUT);
    pinMode(TxD, OUTPUT);

    Serial.print("Started\n");
    setupBlueToothConnection();

}

void loop() {
char recvChar;
    while(1)
    {
        if(blue.available())
        {//check if there's any data sent from the remote bluetooth shield
            recvChar = blue.read();
            Serial.print(recvChar);

        }
        if(Serial.available())
        {//check if there's any data sent from t he local serial terminal, you can add the other applications here
            recvChar  = Serial.read();
            blue.print(recvChar);
            delay(400);
        }
    }
}

void setupBlueToothConnection()
{
  //blue.begin(9600);

  blue.print("AT");
  delay(400);

  blue.print("AT+ROLES");  // set the role as slave
  delay(400);

  blue.print("AT+NAMESlave");   // set the bluetooth name as "Slave" ,the length of bluetooth name must less than 12 characters.
  delay(400);

  blue.print("AT+AUTH1");
  delay(400);
  blue.flush();
}

The output from the Serial Monitor (set as BOTH NL & CR, 9600) as follows:
Started
OKOK+Set:SOK+Set:SlaveOK+Set:1

The problem is when I send AT commands from terminal I get nothing in return.
However if I send AT command from the IDE, I am getting feedback from the bluetooth.


texts:
I have recently written a program which is supposed to change the duty-cycle to keep the feedback voltage measured on A0, A1 constant. The problem is that the Arduino will start crashing at pretty constant intervals if it approaches it's target current. Once it crashes I have confirmed that it restarts the program (but crashes again in a moment).

Here's a sample of the serial output during the crash:

Current A: 65   Current B: 67   PWM A: 174.98   PWM B: 236.00
Current A: 65   Current B: 67   PWM A: 174.98   PWM B: 235.96
Current A: 65   Current B: 67   PWM A: 174.98   PWM B: 235.92
Current A: 64   Current B: 67   PWM A: 175.00   PWM B: 235.88
Current A: 64   Current B: 66   PWM A: 250.00   PWM B: 285114740000000000000000000.00
Current A: 0    Current B: 0    PWM A: 1.30     PWM B: 0.00
Current A: 0    Current B: 0    PWM A: 2.60     PWM B: 1.30
Current A: 0    Current B: 0    PWM A: 3.90     PWM B: 2.60
Current A: 0    Current B: 0    PWM A: 5.20     PWM B: 3.90

And here is all of my code:

#include <MemoryFree.h>

//Program to run on the Vegetarium
//Written by Leon Teichroeb on 12/6/2016

//Hardware description:
//-Oscillator 2A and 2B for the two onboard driver circuits
//-Pin 13 is attached to the "heartbeat" LED
//-Channel A (3) and B (11) current measurements on A0 and A1

//Functionality:
//-Drive Channels at set current

float PWMA = 0;
float PWMB = 0;

int TARGETA = 65;
int TARGETB = 65;

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

  pinMode(3, OUTPUT);
  pinMode(11, OUTPUT);
  TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
  TCCR2B = _BV(CS20);
  OCR2A = (int)PWMA;
  OCR2B = (int)PWMB;
  digitalWrite(3, LOW);
  digitalWrite(11, LOW);

  delay(5000);
}

void loop() {
  int CURRENTA = analogRead(A0) / 4;

  if(CURRENTA < TARGETA) {
    PWMA += (TARGETA - CURRENTA) * 0.020f;
    if(PWMA > 250) {
      PWMA = 250;
    }
  }
  if(CURRENTA > TARGETA) {
    PWMA += (TARGETA - CURRENTA) * 0.020f;
    if(PWMA < 5) {
      PWMA = 5;
    }
  }

  int CURRENTB = analogRead(A1) / 4;

  Serial.println("Current A: " + (String)CURRENTA + "\t" + "Current B: " + (String)CURRENTB + "\t" + "PWM A: " + (String)PWMA + "\t" + "PWM B: " + (String)PWMB);
  //Serial.println("PWM A: " + (String)PWMA + "\t" + "PWM B: " + (String)PWMB);
  //Serial.print("freeMemory()=");
  //Serial.println(freeMemory());

  if(CURRENTB < TARGETB) {
    PWMB += (TARGETB - CURRENTB) * 0.020f;
    if(PWMB > 250) {
      PWMB = 250;
    }
  }
  if(CURRENTB > TARGETB) {
    PWMB += (TARGETB - CURRENTB) * 0.020f;
    if(PWMB < 5) {
      PWMB = 5;
    }
  }

  if(PWMA < 10) {
    digitalWrite(3, LOW);
  } else {
    analogWrite(3, (int)PWMA);
  }
  if(PWMB < 10) {
    digitalWrite(11, LOW);
  } else {
    analogWrite(11, (int)PWMB);
  }

  delay(40);
}

My circuit also provides power for the Arduino through a simple 7815 voltage regulator. The analog input does not exceed a few volts, and the PWM outputs are driving two logic level MOSFETs. If more information on the circuit is necessary please let me know!

EDIT: I have found out that it isn't a bug in the two feedback loops, because both work on their own. It crashes as soon as I use both feedback loops together. As far as I'm aware, there are no shared variables or data between them


texts: Button that gives an Input, Has a small delay --- then gives another

texts:
I'm pretty new to the Arduino scene, and my question will likely be solved simply by some more experienced fellows. I'm trying to create a code for a switch/ button that when you press it, it generates an output--- then waits (delays?) and produces another (after that set amount of time) before ending that transfer of information.  Can any insight be shed on this? What would that look like? For example, the code that I am imagining is something like this :

if(buttonisPressed){

  Function1 = 1;   // Original output is issued

  delay(1000);  // Set time delay for the next output

  Function2 = 1; // The second output follows suit after the set amount of delay time (only after one press, without a secondary)

}

This is a snippet of the code I am using, but I haven't been able to get it to work.

Thanks so much for your help! Any advice at all would be greatly appreciated.


texts: Swap two arrays (using pointers, not copy)

texts:
I've got two arrays, defined as:

uint8_t array1[10];
uint8_t array2[10];

I'd like to swap the arrays (actually the pointers to each array) using code like this:

uint8_t *tmp = array1;
array1 = array2;
array2 = tmp;

However, I keep getting errors like:

invalid array assignment

for the last two lines. I don't recall this being such a problem in traditional C++. I've tried all sorts of casting to no avail. Is there something I'm missing?

I can get the code to run properly if I switch the declarations for the arrays to use new and have them just be more-or-less pointers rather than arrays, but I'd rather not have to do that:

uint8_t *array1 = new uint8_t[10];
uint8_t *array2 = new uint8_t[10];

Code is running on an ARM-based SAMD51 (Cortex M4 processor).

Thanks for any tips!


texts: Unexpected behaviour of blinking LED code

texts:
I'm new to Arduino so this may be a really silly doubt but I'm not finding an explanation for it anywhere online. I first uploaded this code (to blink 5 LEDs) on my Arduino Uno :

 void setup(){
 pinMode(12, OUTPUT);
 pinMode(11, OUTPUT);
 pinMode(10, OUTPUT);
 pinMode(9, OUTPUT);
 pinMode(8, OUTPUT);
}

void loop(){
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(12, LOW);
delay(1000);
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(11, LOW);
delay(1000);
digitalWrite(10, HIGH);
delay(1000);
digitalWrite(10, LOW);
delay(1000);
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(1000);
digitalWrite(8, HIGH);
delay(1000);
digitalWrite(8, LOW);
delay(1000);
}

The 5 LEDs glowed brightly. But when I uploaded the following code (using an if statement to reduce the size of the previous one), the LEDs glowed dimly.

int LEDpin = 13;
void setup(){
pinMode(LEDpin, OUTPUT);
}

void loop(){
digitalWrite(LEDpin, HIGH);
delay(1000);
digitalWrite(LEDpin,LOW);
delay(1000);
if(LEDpin >= 8){
LEDpin--;
} else {
  LEDpin = 8;
  }
}

Also, when I just typed the if statement without the else part, nothing happened after the LED at pin 8 had glowed on and off. Can someone please tell me why the LEDs glowed dimly in the second one and why nothing glowed after LED 8 when I skipped the else part?


texts: How to read 6 RC remote channels using Attachinterupt for every channel

texts: How can i use the attach interupt command and read rc channels in background. I am in doubt that attach interupt is only applied to 2 pins just and cant be used to get data from other pins.


texts:
I have an Uno + WiFi 101 thermometer and I'd like to be able to take it places and easily change WiFi network SSIDs and passwords.  Can I use a TFT screen to make these changes to a sktech or am I stuck using a PC and IDE for this kind of thing?

Can someone provide a sample sketch of what this might look like?  I want to know it's something that's possible before I spend the money on a TFT.

It's possible (let's face it, LIKELY) that I fundamentally misunderstand the capabilities and limitations of the TFT screen.  Sorry for the noobish question.


texts: help adapting a sketch to use a 16x2 lcd

texts:
I have found a great instructable that shares a sketch.  I'm a noob, but i think i do understand it and how to adapt it for my use, but he has used a different display than i have.... and I just don't know how to get the output to display on it.
In the sketch he uses a Oled Display, all i have on hand is a 16x2 I2c LCD.  I have tried to use libraries and other code from other sketches that work on this display, but I just do have the knowledge to make it work.
Can someone help me please?
This is the page:
https://www.instructables.com/Measure-Fuel-Level-With-Arduino/
This is the code:
#include "SSD1306Ascii.h"
#include "SSD1306AsciiAvrI2c.h"
SSD1306AsciiAvrI2c oled;
#define I2C_ADDRESS 0x3C

int TankValue0;
int TankValue1;

void setup() {
  Serial.begin(9600);
  oled.begin(&Adafruit128x64, I2C_ADDRESS);
  oled.setFont(System5x7);
  oled.clear();
}

void loop() {
  int sensorTankValue0 = analogRead(A1);
  int sensorTankValue1 = analogRead(A2);
  TankValue0 = map(sensorTankValue0, 295, 785, 0, 100);
  TankValue1 = map(sensorTankValue1, 295, 785, 0, 100);
  if (TankValue0 < 0) {
    TankValue0 = 0;
  }
  if (TankValue1 < 0) {
    TankValue1 = 0;
  }
  if (TankValue0 > 100) {
    TankValue0 = 100;
  }
  if (TankValue1 > 100) {
    TankValue1 = 100;
  }
  oled.print("T0=");
  oled.print(TankValue0);
  oled.println(" ");
  oled.print("T1=");
  oled.print(TankValue1);
  oled.println(" ");
  oled.setCursor(0, 0);
}


texts: How to calculate required amperage of multiple motors?

texts:
I a very simple question about calculating the amperage I need to run 5 stepper motors from my Arduino Uno.
If I have 5 28BYJ-48 stepper motors(which are 5V and are said to require about 240mA each) all plugged into 5 separate ULN2003 driving boards, and I wire 4 signal wires from the boards to the Arduino, and connect the two power wires for the board to 5V and GND on the Arduino. What voltage and amperage I need to supply to my Arduino for everything to run properly?
I'm worried because I read that the Arduino cannot handle over one amp but 0.24*5>1, although I don't know if the amperage is additive with each additional motor.
Thanks for any answers!


texts: connection for hall sensor 4 pin and arduino nano

texts:
I'm not from electronics background so I don't know what should be the connections. My Hall sensor has 4 pins(AO, GND, +, DO)

So, I have connected hall sensor pins to Arduino nano pins in this order(connection)

AO(Sensor) <-> A4(Arduino)   [Changed from A0 to A4]
DO(Sensor) <-> D4(Arduino)   [Changed from D0 to D4]
+(Sensor) <-> 5V(Arduino)
GND(Sensor) <-> GND (Arduino)

What should be pseudo code? So that if the magnet passes close to the sensor. Arduino should get the output & I'll blink the led on Arduino

This below is my code that I have written so far

int sensorPin = 4; // this is for sensor in analog pin 4
int buttonPin = 4; // we are looking for digital 4
int val;

bool flag = false;

void setup() {
  // put your setup code here, to run once:
  pinMode(buttonPin, INPUT); // defines digital pin 4 as input for LED
  Serial.begin(9600);
}

void loop() {
   int reading = analogRead(sensorPin);

   float voltage = reading * 5.0;
   voltage /= 1024.0;

  if(voltage > 3.0) {
   Serial.print(voltage); Serial.println("volts");
  }
   val = digitalRead(buttonPin);  // read data from digital Pin

   if(val == HIGH) // when the sensor detects a magnetic field
   {
      flag = !flag;
      if(flag){
         digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
      } else {                 // wait for a second
          digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
      }
      //delay(1000);                       // wait for a second
   }
   delay(100);
}

Expected output: It should turn On/Off the LED when voltage goes HIGH

Known issues: It works sometime. It doesn't work sometime. Also it works only when magnet is kept clone. Doesn't detect when I'm waving magnet close to the sensor


texts: Converting TinkerKit to native Arduino pins

texts:
Over the years, I have acquired many TinkerKit modules for my Arduino Uno. My only issue is that I need to find a way to code using the native syntax, and not the less-powerful TinkerKit variation. To do this, I need to know if TinkerKit maps its 3-pin connector to the Arduino Board's pins (ex: 1, 3, 5). If it does, what are the mappings?

Thanks in advance!


texts: HTTP post via GPRS (SIM808) to Azure http endpoint logic app is failing

texts:
I am using a SIM808 with a atmega2560.

I have setup the endpoint in Azure and that works when I try a http post via postman and/or an online http post tool (I get a 202 as result and see data comming into Azure)

I want to send a json package to an Azure http endpoint (smart app) using the function httpPOST in the SIMCom library from itead.

I am connecting to the network:

logging (I printed all that is written to GSM):

AT+CIFSR
DB:STARTING NEW CONNECTION
AT+CIPSHUT
DB:SHUTTED OK
AT+CSTT="provider.net","","" DB:APN OK
AT+CIICR
DB:CONNECTION OK
AT+CIFSR
DB:ASSIGNED AN IP
GPRS status=ATTACHED
AT+CIPSTART="TCP","prod-13.westeurope.logic.azure.com",443
DB:RECVD CMD
DB:OK TCP

Then call the httpPost function from the library with the following variables:

const char server[35] = "prod-13.westeurope.logic.azure.com";
const int port = 443;
const char path[200] = "/workflows/someazureID/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=someazuretoken";
const char parameters[100] = "{\"device\":\"alive\",\"timestamp\":\"09270845\"}";

Part of the httpPost function from the library for sending the data

    int InetGSM::httpPOST(const char* server, int port, const char* path, const char* parameters, char* result, int resultlength)
         ....
    gsm.SimpleWrite("POST ");
    gsm.SimpleWrite(path);
    gsm.SimpleWrite(" HTTP/1.1\r\nHost: ");
    gsm.SimpleWrite(server);
    gsm.SimpleWrite("\r\n");
    gsm.SimpleWrite("User-Agent: Arduino\r\n");
    gsm.SimpleWrite("Content-Type: application/json\r\n");
    gsm.SimpleWrite("Content-Length: ");
    itoa(strlen(parameters),itoaBuffer,10);
    gsm.SimpleWrite(itoaBuffer);
    gsm.SimpleWrite("\r\n\r\n");
    gsm.SimpleWrite(parameters);
    gsm.SimpleWrite("\r\n\r\n");
    gsm.SimpleWrite(end_c);
....

Which gives this output on the serial monitor (I printed all that is written to GSM):

AT+CIPSEND
DB:>
POST /workflows/someazureID/triggers/manual/paths/invoke?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=someazuretoken HTTP/1.1
Host: prod-13.westeurope.logic.azure.com
User-Agent: Arduino
Content-Type: application/json
Content-Length: 55

{"device":"alive","timestamp":"09270845"}

DB:SENT

And then it is waiting for a response:

Starting read..
Waiting for Data............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
CLOSED

Done..
response:
10

CLOSED

which times out I guess.

And I see nothing coming into Azure.

(I am getting data when I try a httpGet on a random site. So hardware, sim and network is working ok I guess)

Any ideas?
thx!


texts: how to write freerun analog samples to a file on MacOS

texts:
I've only just managed to get the Arduino IDE on MacOS set up with my ESP8266 board. My loop is running and I can see the lovely serial output in the Serial Monitor window in the Arduino IDE. I'm going to attach a KY038 sound sensor and I want to sample the analog pin of the KY038 at very consistent intervals and write each sample to the serial port and I want to route ALL of the data written to the serial point to a file.

My big questions are:

1) how do I route all the serial output that my sketch is writing to a file on the mac to which the 8266 is attached via USB cable? This setup seems to write to a file /dev/tty.SLAB_USBtoUART, but I have been unable to inspect the contents of this file/port/whatever either using the screen or tail commands.

EDIT: I have managed to use the screen command successfully to monitor the serial output from my 8266 board. This command shows you the serial output as it is continually written:

screen -L /dev/tty.SLAB_USBtoUART 115200

Where the 115200 is the baud rate of my sketch's serial output. I'm still not sure of the exact steps that would yield a data file on my file system. I expect you'd have to write in a pause in your sketch before it starts writing any serial output and then you could route the screen output to a file like so:

screen -L /dev/tty.SLAB_USBtoUART > /path/to/file.txt 115200 &

The ampersand at the end backgrounds the process. I'm not really sure how to halt that background process, though. Might have to do a kill on its process id? Any advice would be very welcome. This seems a bit kludgy to me. I do see some detail about job control right here which will probably be helpful.

2) I've been told I can do a "freerun" of samples on the ky038 and have the program fire off some interrupt when a certain number of samples has been collected. Can anyone refer me to a sample program which does that sort of thing?


texts: Using HC-12 radio on UNO or NANO without software serial

texts:
On the Arduino UNO and NANO with the serial port connected to an on-board device connected to a USB port, I can obviously send and receive messages to the serial console......now the question:

I have no idea how to use the serial port to send data elsewhere, specifically to an HC-12 radio type device that communicates serially. I cannot use a software serial port because of timing issues, so I need to use the HW port.

During development I expect to use the serial console for diagnostic messages, but I also need to use the port to send and receive data using the radio.

So, how does the handshake/protocol handle both the serial console in the IDE and something else, or better yet, can it handle sending OR receiving data to or from 2 devices at the same time?

Does anyone use the HC-12 type device using the one onboard serial port on an UNO or NANO?

Remember, the goal is to use the HW serial port to communicate with the HC-12 buy issuing Serial.print commands, which logically will also go to the serail console of the IDE.


texts: Hook Arduino up with thermal printer and power both externally

texts:
Disclaimer: I have no connection to adafruit.

A friend and me want to build a little project. We want to connect an arduino to a thermal printer and then print out little fortune-cookie like messages, when a button is pressed. The whole setup should not be stationary and thus we need external, mobile power like batteries.

Since this is our first time using an arduino as well as a thermal printer and we have no clue about electronics, I am asking for help to set everything up without frying the arduino or the thermal printer.

We are using a standart arduino uno rev3 and the Adafruit Tiny Thermal Reciept Printer.

First question: Setting up the power supplies

So the idea was to power the arduino via a 9v battery pack to it's 2.1mm DC port. I think this should work, right?

What I am confused about is the Adafruit Tiny printer. It says it takes 5-9 V, 1.5-2A. Can I just hook up a 9V battery packand clip the caples to the printer? Or what setup do I need so that the printer will recieve enough amperes when printing?

And how would I connect both tools to a single ( larger ?) battery pack?
So that we can turn the power off easily?

Second question: Finding a good button compatible with an arduino and setting it up in the project.

So we have a gerneal idea of how things should work. Somehow we need to connect the button to the arduino which then can register a click via one of it's pins. This click I can then register with my code and from there on things get easy for me. But getting to this point is hard for us.

We don't know which buttons will work and neither how to connect it to the right pin. Which pin should we adress? Digital? Analog?
Does the button need an external power supply as well? Since otherwise the arduino would not register a change of current on a pin, right? Or do we need to connect the button to the whole circuit?

I do a lot of high language engineering and have no real idea about circuits and electronics and my friend is more of a craftsmen so we really appreciate your ideas, setups and help in general!

I am not sure if this is too much to ask but a sketch of the whole setup with a single power source and button would be awesome! Thanks. Really!


texts: what is the fastest shield to add to the sparkfun v3.2 Arduino Uno that will enable me to playback and record hour of short audio dictation

texts:
I have almost no eexperience building electronic kits. I just buoght and began tinkering with sparkfun 3.2 and want to adapt its simon sketch to real audio files
What isis theeasiest to assemble add on shield or breakout not surew hat you call this looked at this one
VS1053 Codec + MicroSD Breakout - MP3/WAV/MIDI/OGG Play + Record - v4


texts: Uno Wifi Rev2 - sending program via WIFI

texts: My new Uno wifi rev2 just arrived and I have one problem.  At the beggining I connected my board via USB and tested with example blink program from WifiNiNA and It worked fine.  When program is runned and I plug in DC power suply and take off USB, my program is still working. And here is my problem. I'm wondering how I can send program/sketch to my arduino without usb just through WIFI. Is it possible? How I can do it?


texts: How to make two small micros communicate with my Arduino over BLE?

texts:
I want to do a project with an Arduino Uno and two other BLE (or regular bluetooth) capable modules. I want the Bluetooth modules to be hooked up to buttons (one button for each Bluetooth module). I then want the Bluetooth-capable modules to send the state of their buttons to a central Arduino board.

Is this possible? Can I have two different BLE boards connected to one Arduino?

I have a RedBear BLE (Bluetooth low energy) shield for my Arduino. What micro-controllers should I get for the peripheral modules? And where can I learn about pairing Bluetooth modules? Everything I read seems to be about pairing Bluetooth boards to a phone.

Can I do this all with BLE or am I going to need to get a new shield for my Arduino to talk with the two peripheral boards?

Thanks.


texts: How do I get my servo to turn using bluetooth, is this a glitch?

texts:
I'm very new to coding with arduino so please excuse my naivety, For an electronics assignment I am making a servo turn back and forth using a HM10 BLE however each time I press a button that sends '0' or '1' to the serial it also sends '200, '0' (being whatever i pressed), 250' all on different lines, so the servo tries turning to 200, 0, then 150 in a quick burst, making it spas out for a split second.

Is there any way i can get rid of the 200 and 250 in the serial or somehow make it only send the '0' or '1'

This is my code so far if needed:

  #include<SoftwareSerial.h>
#include<Servo.h>
Servo x;
int bttx=9;    //tx of bluetooth module is connected to pin 9 of arduino
int btrx=10;    //rx of bluetooth module is connected to pin 10 of arduino
SoftwareSerial bluetooth(bttx,btrx); //defines bluetooth as a dim and reads tx and rx from above

void setup()
{
  x.attach(11);        // servo is connected to pin 11 of arduino
  Serial.begin(9600);
  bluetooth.begin(9600);
}
void loop()
{
  if(bluetooth.available()>0)    //if bluetooth module is transmitting data
  {
    int pos=bluetooth.read(); // store the data in pos variable
    Serial.println(pos);
  }
}

Thankyou for the help and sorry again for the inconvenience, as I said I am only about a week into arduino :) anything helps


texts: Arduino nano digital pins not working with external power source

texts:
We are using an Arduino Nano for simple serial comms to fire a relay from a Windows 10 PC.

Initial issue we had was windows not recognizing the device (COM Port) when the pc is powered off (as per this link: Arduino Nano - USB not present after reboot ) so we powered the arduino nano over a 5V pin and now when Windows starts up the device is recognized.

However, as I'm learning with these chips, nothing is ever that simple. Now the relay that we are firing does not work with external power, but if you unplug the external power then the relay does fire (powered over USB)

The units are at a mine and at the moment and I believe that the problem is that the serial chip is now not responding as per this - from the official Arduino Nano page:

The FTDI FT232RL chip on the Nano is only powered if the board is being powered over USB. As a result, when running on external (non-USB) power, the 3.3V output (which is supplied by the FTDI chip) is not available and the RX and TX LEDs will flicker if digital pins 0 or 1 are high.

Note - I included the above from another question but this no longer appears on the official arduino nano page (can't past link as it's my first post)

The question is how can we get the digital pins on the arduino nano to fire using an external power source and input from a Windows PC?

Thanks

Diagram:


texts:
How can you sense a closed circuit? I want to have 4 pins with disconnected wires and when touched with a fifth wire play a specific note on a piezo buzzer until disconnected again.

This project loops through several keys and checks whether they are being touched using the Capactive Sensor library. I want to do something similar, but not with capacitive sensing. Alternatively, it may work to have the buzzer always trying to play a note, but only sounds when one of the 4 circuits is close. I'm just not sure how that would work in the code.

Here is their code that uses capactive sensing:

#include <CapacitiveSensor.h>
#include "pitches.h"

#define COMMON_PIN      2    // The common 'send' pin for all keys
#define BUZZER_PIN      A4   // The output pin for the piezo buzzer
#define NUM_OF_SAMPLES  10   // Higher number whens more delay but more consistent readings
#define CAP_THRESHOLD   150  // Capactive reading that triggers a note (adjust to fit your needs)
#define NUM_OF_KEYS     8    // Number of keys that are on the keyboard

// This macro creates a capacitance "key" sensor object for each key on the piano keyboard:
#define CS(Y) CapacitiveSensor(2, Y)

// Each key corresponds to a note, which are defined here. Uncomment the scale that you want to use:
int notes[]={NOTE_C4,NOTE_D4,NOTE_E4,NOTE_F4,NOTE_G4,NOTE_A4,NOTE_B4,NOTE_C5}; // C-Major scale

// Defines the pins that the keys are connected to:
CapacitiveSensor keys[] = {CS(3), CS(4), CS(5), CS(6), CS(7), CS(8), CS(9), CS(10)};

void setup() {
  // Turn off autocalibrate on all channels:
  for(int i=0; i<8; ++i) {
    keys[i].set_CS_AutocaL_Millis(0xFFFFFFFF);
  }
  // Set the buzzer as an output:
  pinMode(BUZZER_PIN, OUTPUT);
}

void loop() {
  // Loop through each key:
  for (int i = 0; i < 8; ++i) {
    // If the capacitance reading is greater than the threshold, play a note:
    if(keys[i].capacitiveSensor(NUM_OF_SAMPLES) > CAP_THRESHOLD) {
      tone(BUZZER_PIN, notes[i]); // Plays the note corresponding to the key pressed
    }
  }
}


texts:
I would like to convert a byte *payload to a String, because I want to compare the content of payload to another String.

void mqttCallbackHandler(char *topic, byte *payload, unsigned int length) {
  String payloadstr = ???
  ...
}


texts: Recording of sensor results but only retain the last 3 sets of data

texts:
I'm doing a radiation-seeking robot, which will find the source of the radiation autonomously. But in this case, my robot will spin 180 degrees to detect the nearest source of radiation and 1 set of data recorded is considered for every 180 degree turn. However I think it is not possible to store all of the data in the Arduino due to a storage problem.

Therefore is there any function in Arduino that can only record the last 3 sets of data from the sensor? For example, after it has recorded 3 sets of data, the fourth set data could be recorded by overwriting the first set of data. I would be really grateful if anyone could help me with this.

PS if possible I don't want to install an SD card in my Arduino.


texts: Where does arduino IDE store the latest board selection?

texts:
I'm building a tool to help me automate my uploading process. How do I know where Arduino stores the current preferences - which board, which com port, what serial speed?

If devs are familiar with using multiple boards in the same system ithey'd know it would be really handy to be able to change that


texts:
I had a Roboteq motor controller, but it wasn't fast enough. I'm hoping Arduino will be faster.

Supposing that the transfer is fast enough for my purposes, how can I read angular velocity, given that I have an encoder? Honestly, I'm not totally sure how to hook it up to an Arduino board.
I can't find a name for my encoder... This is the datasheet though.

Can anyone help me with how to hook it up, and what commands to use in MATLAB?

Thanks.


texts: What is the best way I can detect if a ping pong ball has hit the ping pong table?

texts:
The ultimate goal is to track points, which in the case ping pong, is how many times the ball has touched the table.
My concerns are with how light the ball and therefore the impact on the table will be. Is this too light for something like a vibration sensor to register?
Would you imagine the sensor working better on the paddles or the table?
I'm open to other suggestions on more reliable ways to track other than vibration. Definitely new to arduino.


texts:
I want to connect a PCF8575c pin extender to an ESP32, so that I can light 12 LEDs. The problem is that after the connection, when I try to use an I2C Scanner, it shows me a lot of different addresses, not a constant one. Could this happen from a pin fault? I am using this library:
https://github.com/xreef/PCF8575_library

Also, the I2C scanner can be found here: https://playground.arduino.cc/Main/I2cScanner/

And the pins that I use for the LEDs are defined this way:

  pcf8575.pinMode(P0, OUTPUT);
  pcf8575.pinMode(P1, OUTPUT);
  pcf8575.pinMode(P2, OUTPUT);
  pcf8575.pinMode(P3, OUTPUT);
  pcf8575.pinMode(P5, OUTPUT);
  pcf8575.pinMode(P6, OUTPUT);
  pcf8575.pinMode(P11, OUTPUT);
  pcf8575.pinMode(P12, OUTPUT);
  pcf8575.pinMode(P14, OUTPUT);
  pcf8575.pinMode(P15, OUTPUT);
  pcf8575.pinMode(P16, OUTPUT);
  pcf8575.pinMode(P17, OUTPUT);

The link to the exact PCF8575c:
https://www.aliexpress.com/item/2038559527.html?spm=a2g0o.productlist.0.0.3f8331ebu0zuwr&algo_pvid=5e9fc157-a422-4847-acf4-8618a2d365ea&algo_expid=5e9fc157-a422-4847-acf4-8618a2d365ea-2&btsid=0ab6f82415840969999872503e3228&ws_ab_test=searchweb0_0,searchweb201602_,searchweb201603_


texts:
I'm trying to build a smart thermostat for a particular application. I have the following design criteria and goals for the system:

Must be able to set up and monitor the device from either a mobile
phone or local network device.
No go on Ethernet or other hardwired connection, except for initial setup.  This must be a wireless solution. I'm presuming WiFi is best.
Needs a clock, an on time and an off time setting.
The system does a system time verification check once daily.
Needs a temperature input.
Needs to run an existing heater system (24v) thru a relay.
120v AC power (battery backup not required.)
Needs to be "hidden" in existing wall as much as possible.  (i.e. small & compact)  My intent is to hide the unit behind a double wide electrical duplex dead panel. (i.e. 4" x 4" nominal access thru drywall)

Here's a visual of my design intent package:

As I review a number of different hardware controller devices, I can see some issues.  I am very familiar with the Intel Edison, and I know exactly how to do this project there, including using the controller as a stand alone web host. (The Edison uses Yocto Linux to create a node.js server using http module.)  I was hoping to save a few $$ on hardware using an alternative controller but not sure that will work.  I've been wading thru the code for both the Photon and generic Arduino devices, and I'm getting the impression that I may need a custom server / api tool for a web page interface.  Its not clear that those hardware choices will support an interactive web page, particularly for easy user data update via browser Submit button.  That's not a big problem, I'm a freelance software developer, handy in C/C++/Java, PHP and JavaScript. And as for the Raspberry Pi, I have no experience but the pricing on some of their boards is below $15.

Here are my questions:

Has anybody used an Arduino board to host an interactive web page, including user input via Submit / Form ?  (Can I declare a local network static IP address for an Arduino?)
Has anybody used an Particle Photon board to host an interactive web page, including user input via Submit / Form? (It looks like declaring a local network static IP address on a Photon is anything but easy...)
Has anybody written an API Restful server for their Arduino, with both get and put functionality?  (I'm thinking PHP, or node.js makes the most sense for me.)  I know if I have to use Dynamic IP addressing to the controller, that I can always make an API system work for the system.
Other comments?


texts: PWM Control, How to stop LED from Flickering?

texts:
What is required is controlling the brightness of an LED using both Buttons and a Potentiometer,
Button A: Increase

Button B: Decrease /Dim

Potentiometer: Increase and Decrease,

This however must happen on 1 single circuit and must display the results on an LCD.

If I do this separately, meaning buttons without potentiometer and visa versa, I win, the moment I combine the two. I get flickering when working the buttons, due to the potentiometer.

Alternative Research:https://www.instructables.com/id/Smooth-Potentiometer-Input/

Code Below

#include <LiquidCrystal.h>
#include <Wire.h>
// ------------------------------------------------------------

int LED1          = 9;
int ButtonLeft    = 8;
int ButtonRight   = 7;
int brightness    = 0;

// ------------------------------------------------------------
byte buttonState1     = 0;
byte lastButtonState1 = 0;

byte buttonState2     = 0;
byte lastButtonState2 = 0;

unsigned long switchMillis;

// ------------------------------------------------------------

int potValue1 = 0;
int potValue2 = 0;
int potPin= A0;
int readValue;
int writeValue;

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

// ------------------------------------------------------------
void setup() {

  lcd.begin(16, 2);
  pinMode (potPin, INPUT);
  pinMode(LED1,OUTPUT);
  pinMode(ButtonLeft,INPUT);
  pinMode(ButtonRight,  INPUT);
  lcd.clear ();
}

// ------------------------------------------------------------
void loop(){

    if (millis() - switchMillis >= 5)
  {
    switchMillis = millis();
    checkSwitches();
  }

   readValue = analogRead(potPin);
   writeValue = (255./1023.) * readValue;
   analogWrite(LED1, writeValue);

    potValue1 = analogRead(potPin) / 10;
    potValue2 = potValue1 / 1.02;

    lcd.setCursor(0,0);
    lcd.print("Potent=");
    lcd.print(potValue1);
    lcd.print("%");
    delay(100);
    lcd.print(" ");
    delay(1);
}

void checkSwitches() {

    analogWrite(LED1, brightness);
    delay(10);

  buttonState1 = digitalRead(ButtonLeft);

  if(buttonState1 == HIGH){
    brightness--;
    if(brightness < 0){
      brightness = 0;
    }
  }

  buttonState2 = digitalRead(ButtonRight);

  if(buttonState2 == HIGH){
    brightness++;
    if(brightness > 255){
      brightness = 255;
    }
  }

 lcd.setCursor (0,1);
 lcd.print ("Brightness=");
 lcd.print (brightness);
 lcd.print ("   ");
}


texts: Create New Serial Class Inheriting from Stream

texts:
How should I inherit from Stream, for creating a new class MySerial able to be initialized from a Stream0 instance?.

The error so far is: "cannot declare variable 'mySerial' to be of abstract type 'MySerial'".

If I make a class MySerial not inheriting, but adding a property Stream, everything works fine, except the new call mechanism for the resend() function, created to accept Stream instances.

EDIT: This is the edited code. Current error is: "expected unqualified-id before '=' token".

MySerial.h

class MySerial:public Stream{
    private:
        int param;
    public:
        MySerial(){}; // OK
        MySerial(Stream &Serial0){MySerial=&Serial0} // Here is the question
        // Stream Implementation
        int available(){return available();}
        int read(){return read();}
        int peek(){return peek();}
        size_t write(uint8_t c){return write(c);}
        using Print::write;
};

MySerial.ino

#include <MySerial.h>
#include <SoftwareSerial.h>

SoftwareSerial swSerial(6,7);
MySerial mySerial(swSerial);

void setup(){}
void loop(){
    if (mySerial.available()){
        c=mySerial.read();
        resend(mySerial,c);
    }
}
// This function should accept any Stream: SoftwareSerial, MySerial, Serial...
void resend(Stream &Stream0, char c){
    Stream0.write(c);
}


texts: press button: servo move - hold X time - move back issue

texts:
Besides being a total noob I've been lurking and reading like mad over the last week to understand how to get my servo to move to X position when a button is pushed, have it wait Y time, and return to the starting position.  I've come up with this code but could use some guidance.

#include <Servo.h>

const int buttonPin = 8;
const int servoPin = 9;
int buttonState = 0;
int directionState = 0;
Servo servoOne;
int pos = 0;

void setup() {
  servoOne.attach(9);
  servoOne.write(directionState);
  pinMode(buttonPin, INPUT);
}

void loop() {
  buttonState = digitalRead(buttonPin);
  if (directionState == 0) {
    if (buttonState == HIGH) {
      directionState = 1;
      for (pos = 0; pos < 180; pos = pos + 1) {
        servoOne.write(pos);
        delay(5);
      }
    }
  } else if (directionState == 1) {
    delay(5000); {
      directionState = 0;
      for (pos = 180; pos > 1; pos = pos - 1) {
        servoOne.write(pos);
        delay(5);
      }
    }
  }
}


texts:
I'm trying to print the information, which is received from the other ESP32 by CAN transceiver, on an OLED. The CAN bus is working perfectly, as the 'HELLO WORLD' is already be received. But I can't print the received 'HELLO WORLD' on OLED (also the OLED is work). The code shows below,

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

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

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

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

  if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
    Serial.println(F("SSD1306 allocation failed"));
    for (;;);
  }
  delay(2000);
  display.clearDisplay();
  display.setTextColor(WHITE);

  Serial.println("CAN Receiver");
  CAN.setPins(16, 17);
  // start the CAN bus at 500 kbps
  if (!CAN.begin(500E3)) {
    Serial.println("Starting CAN failed!");
    while (1);
  }
}

void loop() {
  // try to parse packet
  int packetSize = CAN.parsePacket();

  if (packetSize) {
    // received a packet
    Serial.print("Received ");

    if (CAN.packetExtended()) {
      Serial.print("extended ");
    }

    if (CAN.packetRtr()) {
      // Remote transmission request, packet contains no data
      Serial.print("RTR ");
    }

    Serial.print("packet with id 0x");
    Serial.print(CAN.packetId(), HEX);

    if (CAN.packetRtr()) {
      Serial.print(" and requested length ");
      Serial.println(CAN.packetDlc());
    } else {
      Serial.print(" and length ");
      Serial.println(packetSize);

      // only print packet data for non-RTR packets
      while (CAN.available()) {
        Serial.print((char)CAN.read());
      }
      Serial.println();
    }

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

  display.clearDisplay();

  display.print((char)CAN.read());

  display.display();
}


texts:
I have a shield with a SIM for GSM/GPRS communications and GPS module.
As visible in top-left corner its name is "SIM908-C EVB v1.0 designed by UNV".

I found some basic information on Arduino forum but they are discordant about baud rate so I tried different configuration: https://forum.arduino.cc/index.php?topic=302982.0

I tried to use several libraries (such as sim900 or tinyGPS) for GPRS communication or simply for getting GPS position, but without results. Shield not respond to serial commands at any baud rate.

Connections that I used:

shield <--> aruino mega
GPRS TXD <--> D2
GPRS RXD <--> D3
GPS TXD <--> D4
GPS RXD <--> D5
GND <--> GND
5V <--> VCC_MCU

Obviously I set D2..D5 in library according to TX/RX pins on shield.

I also tried with a simply code to send AT commands and... no results again.
Here is the code:

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

void setup() {
    Serial.begin(115200);
    Serial.println("Begin");
    mySerial.begin(115200);
}

void loop() {
    if (mySerial.available())
        Serial.write(mySerial.read());
    if (Serial.available())
       mySerial.write(Serial.read());
}

Shield seems to be well powered and connected to SGM net. Infact:

power led: is on
ring led: is on
net status: blinks one time in three seconds

Has someone used this shield? What is a good library to use?
Every help is very appreciated.


texts: Can I do parallel processing in Arduino?

texts:
I recently got to work with Arduino and I want to get parallel input from 5 LDRs and at the same instance I need to light a LED corresponding to that LDR if the resistance got high.

I read about a finite state machine, but I couldn't understand how it works.

Is it the only way for this type of problem or are there any other way?


texts: How come my switch is triggering with out pushing the button?

texts:
New here, sorry If my formatting is bad.

int button = 2;
int relay = 3;
int speaker = 4;

void setup()
{

  pinMode(button, INPUT_PULLUP);
  pinMode(relay, OUTPUT);
  pinMode(speaker, OUTPUT);

}

void loop()
{
  if(digitalRead(button) == 0)
  {
    digitalWrite(relay, HIGH);
    tone (speaker, 100, 300);
    delay (3000);
  }
  else
  {
    digitalWrite(relay, LOW);
  }
}

I want the relay to trigger and stay open only while the button is pressed.   However for some reason touching pin 2 triggers the relay and sound, even if I'm not connecting it to the ground.

If i remove the tone (speaker, 100, 300); it only triggers when the button connecting pin 2 to ground is pressed, but obviously doesn't play the tone.


texts:
I have a few pic chips, mainly pic16f72 and pic16f73 on old ups circuits, realized they are not that bad. Their adc capabilities are my point of focus.

I have an esp32 (my first mcu) and i am very disappointed mainly because its adc being crap, I did some research on programming pic chips, some could be programmed via an arduino but my chips were not mentioned anywhere. I wanna program them via my esp32..

Is there a way to program them via arduino (esp32 in my case)? I can build some basic circuits but diy pic programmers require a preprogrammed pic chip which I can't produce if I can't program one already.


texts: Implementing DES or AES Encryption with DateTime Synchronization on Uno

texts:
We are trying to implement AES or DES encryption using an Arduino Uno.

We have a keypad module attached that will be used to input integers. A String should be generated based on the entered data and encrypted using AES or DES.

We have tried several online libraries with no success due to the constraints put on the "plain text" size.

An example pseudo-code for the above:

string key = "This is a key";
string plain = "This is the keypad input" + keypadInput + "and some other random stuff"; <- This should have any size.

var cipher = AES.encode(plain, key);
print(cipher);

var decoded = AES.decode(cipher, key);
print(decoded);

Could someone please point to the right direction on how to do this?


texts: Stepper motor driver not working properly

texts:
I have a problem. I am following this guide about controlling a NEMA 17 stepper motor: https://www.makerguides.com/a4988-stepper-motor-driver-arduino-tutorial/
I uploaded the code to my arduino uno and powered on everything, but the stepper motor doesn't rotate, except when I put my finger on the metal screw of the a4988 driver. The arduino is powered by a 5v 1A adapter and the a4988 driver is powered with a 12v 2amp adapter.
What is causing this?


texts: ESP32 doesnt save every string to SD Card

texts:
My code initializes, the header (the ID; Value string) for the .csv file gets saved, but the dataString which is the most important part doesnt save to the .csv file.

I get an arraypointer to the start of the array. I dont have much experience with pointers but i dont get any errors.

The best solution would be if i could put everything into the "write matrix to SD"-function. Anyone has an idea? I am just dumbfounded because everything works perfectly without the arraypointer and i dont know what to try.

My setup()

  Serial.begin(115200);

  p_EKG_state_1 = &EKG_state_1;

  pinMode(CS_Pin, OUTPUT);
  if(!SD.begin(CS_Pin))
    {
      Serial.println("Card failed or not present");
    }

  EKG_data_transmision.matrixData = SD.open("/data.csv", FILE_APPEND);  //erstelle data.csv datei

  if(EKG_data_transmision.matrixData)
    {
    String header = "ID; Value;";
    EKG_data_transmision.matrixData.println(header);
    EKG_data_transmision.matrixData.close();
    Serial.println(header);
    Serial.println("card init sucess");
    }
  else
    {
    Serial.println("Couldnt open vector data file");
    }

  //Serial.println(ESP.getFreeHeap());
  pinMode(LED_BUILTIN, OUTPUT); // TEST OUTPUT LED PIN

  pinMode(btn_modus.PIN, INPUT_PULLUP); // MODUSAUSWAHL TASTER
  attachInterrupt(btn_modus.PIN, isr, FALLING); // MODUS TASTER hört auf fallende Flanke und führt dann Funktion isr aus
  WiFi.begin(ssid, password); // Verbinde mit WLAN

  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); // initialisiere Zeit variablen
  EKG_state_1.set_state(1);

}

My function that writes the matrix/arraypointer to the SD

bool  EKG_data_transmision::write_matrix_to_SD(unsigned short *array_pointer) // Übertrage , unsigned short id
{

   if(!SD.begin(CS_Pin))
  {
    Serial.println("Card failed or not present");
    return 1;
  }
  matrixData = SD.open("/data.csv", FILE_APPEND);  //erstelle data.csv datei

  if(matrixData)
  {
    //look if data.csv exists

    while(matrix_coloum < 3071)
    {
      if(matrix_coloum == 1024 || matrix_coloum == 2048)
      {
          header = "ID; Value;\n";
          matrixData.println(header);
      }
      dataString = String(matrix_coloum) + ";" + String(*array_pointer) + "\n";
      matrixData.println(dataString);
      Serial.println("This is datastring:");
      Serial.println(dataString);
      array_pointer++;
      matrix_coloum++;
    }

  }

  else{
    Serial.println("Error writing to file !");
}
  matrixData.close(); // close the file

  return 0;
}

My class with all the inits

class EKG_data_transmision
{
  private:

    String dataString;
    String header;
    unsigned short matrix_coloum = 0;

  public:
    EKG_data_transmision();

    File matrixData;

    //Definiere Funktionen:
    bool write_matrix_to_SD(unsigned short *array_pointer);
    bool delete_matrix_from_SD(unsigned int record);


texts:
I'm learning Arduino (school and from myself).

We have the following code:

temp = Wire.read();
temp = ~temp;
temp = temp - 1;

This code is made to read, then print positive and negative values from a temp sensor. If you need more parts of the code, let me know.

I don't understand what does the ~ symbol, can someone help me?

Thanks.


texts: How to fix 12V RGB LED Strip connection to NodeMCU?

texts:
I am trying to hook 12V RGB Led Strip (LTROP SMD 5050 RGB LED Light Strip) to a NodeMCU unit. I know there are many different tutorials on this and I am very new to wiring and electric circuits.

I used BUZ91A n-MOSFETs and 150 Ohm resistors for each of the RGB channels, and the board is using it's own power supply via usb.

I use very simple code to check if the setup works:

#define REDPIN D3
#define GREENPIN D1
#define BLUEPIN D2

#define FADESPEED 5     // make this higher to slow down

void setup() {
  pinMode(REDPIN, OUTPUT);
  pinMode(GREENPIN, OUTPUT);
  pinMode(BLUEPIN, OUTPUT);
  Serial.begin(115200);
  Serial.println("Finished setup");
}

void loop() {
    analogWrite(REDPIN, 800);
    analogWrite(BLUEPIN, 1020);
    analogWrite(GREENPIN, 400);
    delay(100);

  Serial.println("Finished loop");
}

I suspect nothing works because NodeMCU and the LED are using different power sources and the fact they have common ground doesn't seem to be everything required.


texts: How come my code does not wait for a specific time before going into an if statement?

texts:
I have an HC-SR04 attached to a servo. When the 90 degree reading is less than 30 cm, I want the motor to take 2 seconds to turn to 130 degrees, get a measurement on the right, and turn back to 90 degrees. My code does not seem to work. Even though I tell it to wait for 2000 ms, it skips directly to the if statement where the turning to 90 degrees is done. Here is the main code:

 #include <Servo.h>
#define trig 22
#define echo 24
long duration;
boolean turned130 = false;
int cm50, cm, cm130;
Servo servo;
boolean checkRight = false;
boolean mainPing = true;
unsigned long counter;
unsigned long servoTimer = millis();
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(echo, INPUT);
pinMode(trig, OUTPUT);
servo.attach(12);
servo.write(90);
delay(2000);

}

void loop(){
counter=millis();//my timer
  if(((counter-servoTimer) >= 250) && mainPing){//distance measured 4 times a second
    ping();
    cm=duration/29.1/2;
    Serial.println(cm);
    servoTimer=counter;//this if statement works fine
  }
  if((cm<30) && mainPing){

    mainPing=false;//makes the 90 degree ping and this if statement unable to run
    checkRight = true;//enables next if statement to run
    servoTimer=millis();
    servo.write(130);
    cm=30;//so that this if statement does not get called again until distance is obtained
    Serial.println("Inside less than 30 loop");//I added this for debugging, to let me know when the loop is called

  }
  if(checkRight && ((counter-servoTimer) >= 2000)){//after 2 seconds passes

    checkRight=false;
    ping();
    cm130 = duration/29.1/2;
    mainPing = true;//enable to other 2 if statements to run
    servoTimer=millis();
    Serial.println(cm130);
    servo.write(90);//turn motor back
    Serial.println("Inside other loop");//for debugging

  }

  delay(2);
  }

void ping(){

    digitalWrite(trig, LOW);
    delayMicroseconds(2);
    digitalWrite(trig, HIGH);
    delayMicroseconds(10);
    digitalWrite(trig, LOW);
    duration = pulseIn(echo, HIGH);

}

This is what I got in the Serial monitor:

25//distance triggers 2nd if statement
Inside less than 30 loop
261
Inside other loop
13
Inside less than 30 loop
14
Inside other loop
14
Inside less than 30 loop
14
Inside other loop
3242
13
Inside less than 30 loop
14
Inside other loop

This all happened within milliseconds. There was no 2 second pause and the servo never turned. What is wrong with my code that prevents the motor from turning and waiting 2 seconds? The order of the Serial messages is correct, but it is happening fast.

EDIT:

When I remove the Serial messages and disconnect from the computer, it kind of works. By that, I mean it turns and waits for 2 seconds 50% of the time. Other times, the servo just shakes a little bit and stops.

Another thing I noticed is that if I leave only Serial.println(cm) message and Serial.println("Inside less than 30 loop"), this is the result that I observe.

    12
    13
    Inside less than 30 loop

    15
    3
    Inside less than 30 loop

For some reason the loop does not get triggered the first time. Is there a possibility that I have a defective Arduino Mega?

EDIT 2:

I tested the same setup on an official Arduino Uno and it did not work either. This means that I do not have a broken Arduino. Could the servo motor be broken? That won't explain the Serial messages though.


texts: Getting sensor data wirelessly from arduino to PC

texts:
I am working on a project that involves sending motion sensing data wirelessly from an arduino to computer. Sensor readings have to be transmitted continuously (say every mili second). I am not sure if Xbee is my bet. I came across this link
which suggest s that there should be atleast 10 ms delay between packets if you're using xbees.

What are your experiences with xbees? I don't want to waste money.


texts: Can ESP 32 use the wire library exactly like that was in Arduino?

texts:
Compare the YouTube video and this webpage, the former one made programming very different in ESP32 and that was in Arduino nano, while the webpage seemed to imply that they work exactly the same.

Can we use the same code for standard Arduino library, like wire library, for ESP32 and ESP8266, or do we have to do something different?


texts: Reading data from multiple sensors from Arduino with ESP8266

texts: I am trying to do a project where I need to get data from multiple sensors simultaneously. I am planning to use a Arduino to get the readings from the sensors. I am thinking to control the Arduino using ESP8266 as I would finally like to have internet capabilities for my project. I have worked with Arduino before but this is my first time with ESP8266 and I don't know much about. What I would like to know is if its feasible? I read that I need to use SoftwareSerial library to achieve this. Am I correct? I have tried to google for similar examples but most of the results direct to using a single pin on the Arduino controlled by ESP8266 and the Blynk app. Apart from that I could not find much information. I would be very much grateful if you could point out some similar projects or examples. Thanks a lot for your time in advance.


texts: Safe changes in the Arduino Libraries and use them

texts:
I changed 2 Arduino Libraries because i have a 9 bit data protocol, now i want use the amended Libraries on my Arduino mega2560.

At first i have set a 9 bit data mode that can i do when i set the UCSZ12 bit on 1(original code under the following link: https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial.cpp#L103 ):

void HardwareSerial::begin(unsigned long baud, byte config)
  ...
  sbi(*_ucsrb, RXCIE0);
  sbi(*_ucsrb, UCSZ12);  // chance: set 9-bit data mode on 1
  cbi(*_ucsrb, UDRIE0);
  ...

At second i want throw an interrupt when the 9th bit is an 1 that can i do when i change the code like the follow (original code under the following link : https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/HardwareSerial_private.h#L101 ):

void HardwareSerial::_rx_complete_irq(void)
  if (bit_is_clear(*_ucsra, UPE0)) {
    bool is_address = UCSR0B & _BV(RXB80);
    unsigned char c = *_udr;
    if (is_address) {
      do_something_with_address(c);
      return;
    }
  rx_buffer_index_t i = (unsigned int)(_rx_buffer_head + 1) % SERIAL_RX_BUFFER_SIZE;
...

What must i do with the two file´s?

How can i use the changed Libraries?


texts: double to char* conversion. Weird results from dtostrf

texts:
Here’s the code:

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

    double lat = 1111.11;
    double lon = 4444.44;

    const byte len{10};

    char sLat[len];
    char sLon[len];

    dtostrf(lat, len, 2, sLat);
    Serial.println(sLat);

    Serial.println("---");

    dtostrf(lon, len, 2, sLon);
    Serial.println(sLon);
    Serial.println(sLat); // <-- prints nothing!

    Serial.println("---");

    dtostrf(lat, len, 2, sLat);
    Serial.println(sLat);
    Serial.println(sLon); // <-- prints nothing!
}

void loop()
{
}

Here’s the output:

   1111.11
---
   4444.44

---
   1111.11
   4444.44   1111.11

As you see. Every next call for dtostrf ruins the previous results, in a weird way.

What’s the problem?


texts:
I am an Arduino (and C/C++) newbie so apologies if I am missing something obvious.

I am using IRremote (github link) as my IR library.

I can get the simple send and receive demos working  individually.

However, I cannot get send AND receive working in the same Arduino at the same time.

I do not wish to do something like the "IRrecord" example but what I do want to do is have Arduino send and receive at all times and then trigger alarm/LED once the "beam" is broken.

I am using a TSOP 22 series as my IR receiver. I have tried to use protothreads but no luck. Any tips appreciated.

My current code snippet:

#include <IRremote.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);
IRsend irsend;

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("IR Receiver... Started");
}

void loop() {
  //single threaded nature seems to break below

  // i want to start receiver here
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  //delay(5000);

  //trying to send here
  for (int i = 0; i < 3; i++) {
    irsend.sendSony(0xa90, 12);
    Serial.println("Sent Sony......");
    delay(40);
  }
  //delay(5000); //5 second delay between each signal burst
}


texts:
I am using BMP 280 for an altimeter to measure the altitude. Once all connected and uploaded the BMP280test code from Adafruit, the serial monitor says busy. But still, when I switch the port in tools, nothing shows on the serial monitor. How do I get the monitor to start displaying data?
Thanks
Code:
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_BMP280.h>

#define BMP_SCK  (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS   (10)

Adafruit_BMP280 bmp; // I2C
//Adafruit_BMP280 bmp(BMP_CS); // hardware SPI
//Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO,  BMP_SCK);

void setup() {
  Serial.begin(9600);
  Serial.println(F("BMP280 test"));

  if (!bmp.begin()) {
    Serial.println(F("Could not find a valid BMP280 sensor, check wiring!"));
    while (1);
  }

  /* Default settings from datasheet. */
  bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,     /* Operating Mode. */
                  Adafruit_BMP280::SAMPLING_X2,     /* Temp. oversampling */
                  Adafruit_BMP280::SAMPLING_X16,    /* Pressure oversampling */
                  Adafruit_BMP280::FILTER_X16,      /* Filtering. */
                  Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */
}

void loop() {
    Serial.print(F("Temperature = "));
    Serial.print(bmp.readTemperature());
    Serial.println(" *C");

    Serial.print(F("Pressure = "));
    Serial.print(bmp.readPressure());
    Serial.println(" Pa");

    Serial.print(F("Approx altitude = "));
    Serial.print(bmp.readAltitude(1013.25)); /* Adjusted to local forecast! */
    Serial.println(" m");

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


texts: Does restarting Yún configuration mess up Arduino or its SD card?

texts:
I noticed something odd recently - a Yún, that was working previously, wouldn't connect.

After logging in to the web setup, setting the access point and password (which hadn't changed), and save & restart, it connected. Unfortunately, it still doesn't work, and after ssh into it, I find I cannot ls /mnt/sd/ or sda1. It just sits there, requiring Ctrl+C, and gives no output.

Did I reset the Arduino or Linux somehow by setting up access point again, or could my SD card be broken after months of heavy logging?


texts: Arduino esp8266 some times data will not be sent to thingspeak.com

texts:
I have made an arduino IOT that sends temperature data to thingspeak and works fine . Now I have two questions
1-  In spite of active wifi connection from esp8266 toward the web , but why sometimes that is random the sensor data will not be sent to thingspeak.com ?
2- I need an android app that monitors the wifi and shows the sensor data that is collected by arduino and sent via wifi by esp8266 toward android hot spot , is any app available for this purpose?
Thanks a lot


texts: Send data from one NodeMCU to another NodeMCU using Serial Communication

texts:
i am using NodeMCU (ESP8266) to communicate with another NodeMCU (ESP8266) using Serial Communication. Because i am using ESP-NOW to communicate and ESP-NOW and WiFi can not work together very well so trying with this serial communication option.
Here is how i connected the pins:
   Slave ->   Master
    D1    ->   D2
    D2    ->   D1
    GND   ->   GND

Here is how my sketch looks like:
Sender.ino
#include <Wire.h>

void setup() {
  Serial.begin(115200);
  Wire.begin(D1, D2); /* join i2c bus with SDA=D1 and SCL=D2 of NodeMCU */
}

void loop() {
  // put your main code here, to run repeatedly:
   Wire.beginTransmission(5); /* begin with device address 8 */
   Wire.write("Hello ESP 2");  /* sends hello string */
   Wire.endTransmission();    /* stop transmitting */

   Wire.requestFrom(5, 4); /* request & read data of size 13 from slave */
   while(Wire.available()){
      char c = Wire.read();
    Serial.print(c);
   }
   Serial.println();
   delay(1000);
}

Receiver.ino
#include <Wire.h>

void setup() {
 Wire.begin(5);
 Wire.onReceive(receiveEvent); /* register receive event */
 Serial.begin(115200);           /* start serial for debug */
}

void loop() {
 delay(100);
}

// function that executes whenever data is received from master
void receiveEvent(int howMany) {
 while (0 <Wire.available()) {
    char c = Wire.read();      /* receive byte as a character */
    Serial.print(c);           /* print the character */
  }
 Serial.println();             /* to newline */
}

But the communication is not working at all, not sure where i am wrong. It can code wise or may be via connection wise or it might be possible that NodeMCU to NodeMCU connection is not possible at all!
Thank you!


texts:
I have multiple Arduino Nano boards.
I am able to compile or upload code only once. If I try to compile/upload again I get an error: "Error compiling for board Arduino Nano". However there is a workaround: to be able to upload again I change something in tools menu for example board or processor.
I tried all of the nanos and all of the ports.

The error message is below (verbose is enabled).

The problem appeared from nowhere.
Thank you in advance!

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Nauris\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328old -vid-pid=1A86_7523 -ide-version=10812 -build-path C:\Users\Nauris\AppData\Local\Temp\arduino_build_956544 -warnings=none -build-cache C:\Users\Nauris\AppData\Local\Temp\arduino_cache_309115 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Nauris\Documents\Arduino\RC\wifi_arduino\wifi_arduino.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Nauris\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328old -vid-pid=1A86_7523 -ide-version=10812 -build-path C:\Users\Nauris\AppData\Local\Temp\arduino_build_956544 -warnings=none -build-cache C:\Users\Nauris\AppData\Local\Temp\arduino_cache_309115 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA-1.3.0.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc-7.3.0-atmel3.6.1-arduino5.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude-6.3.0-arduino17.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Nauris\Documents\Arduino\RC\wifi_arduino\wifi_arduino.ino
Using board 'nano' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used...
Error compiling for board Arduino Nano.


texts: Controlling bigger motors with an arduino board

texts:
i am german and my english is not the best, anyway i hope you will understand my problem.
At the moment i construct a little car with some friends. We have still completed the frame and now we think about controlling it in a electronic way. For example with a controller of a playstation or with our smartphones, however, it should be electronic, so i think about to do this with an arduino board.

We have two motors. One for the direction and the other one for the movement.
The first has about 8 ampere and about 12 volt, the other has 800 watt, so around 40 ampere and 24 volt.

My question is, whether it is possible and if so how to control them (or one them) with an arduino board and what do i need in addition?

It would be great if you could help us :)


texts:
I was supposed to first create a 4x1 MUX using AND and NOT gates. The 4 input data lines (io,i1,i2,i3) were 4 PWM pins from the arduino (3,5,6,9), with analogWrite() values as 100,150,200,250 respectively, and the selection lines were taken from two slide switches.

int i0=100;
int i1=150;
int i2=200;
int i3=250;

void setup()
{
  pinMode(5, OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(9,OUTPUT);
  pinMode(3,OUTPUT);

  analogWrite(3,i0);
  analogWrite(5,i1);
  analogWrite(6,i2);
  analogWrite(9,i3);

  Serial.begin(9600);
}

void loop()
{

}

Simulation link: https://www.tinkercad.com/things/cRZNvuwhZYV
The voltmeter + is connected to the output of the MUX. Both selection lines are HIGH, so the output is i3, which has the pWM value 250. So the voltage should be (250/255)*5, i.e about 4.9 V, which is what the meter shows. (The servo is present but not connected.)
The voltmeter values are in accordance for all the 4 possible combinations. In short, the 4x1 MUX is working perfectly.
(it was important for me to clarify this as otherwise people might have thought of the MUX implementation as the problem with my lsubsequent circuit , and with the messy wiring, it would've been impossible to confirm whether or not this is the case. However, as I have clearly shown, the problem is NOT with the MUX).
Next, I tried to control the servo using this MUX. I connected the servo control pin to the MUX output:

#include<Servo.h>
Servo s1;
Servo s2;
Servo s3;
Servo s4;

int i0=100;
int i1=150;
int i2=200;
int i3=250;

void setup()
{
  pinMode(3,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(9,OUTPUT);

  analogWrite(3,i0);
  analogWrite(5,i1);
  analogWrite(6,i2);
  analogWrite(9,i3);

  s1.attach(3);
  s2.attach(5);
  s3.attach(6);
  s4.attach(9);

  Serial.begin(9600);
}

void loop()
{

 s1.write((i0*180)/255);
 s2.write((i1*180)/255);
 s3.write((i2*180)/255);
 s4.write((i3*180)/255);
}

For instance, I thought if both switches were on, then the output is i3,(which was coming from pin 9), so
only s4.attach(9); and s4.write((i3*180)/255); will work. (As, it is apparent that the control pin is connected to pin 9 in this case).
The servo does move around when I change the switches to on off combinations, however,something drastic has happened to the voltmeter values, which tells me that my code is messing with the MUX output. The output voltages fluctuate rapidly between 97 and 180 mV.
What exactly have I done wrong, and how exactly am I supposed to control the Servo, then?


texts: Bluetooth OBD2 ELM327 connectivity issues

texts:
I made a little project using an Arduino UNO, a 3.5" display, a HC-05 bluetooth module and an ELM327 (cheap ebay clone). I managed to establish communication, read the data, interpret and display it, but only one problem remains that keeps bothering me.

After some exchanges of data between Arduino and the OBD2 adapter, communication just drops.  I don't know if its from the HC-05 or ELM327. As far as I could debug it, the data from ELM327 comes incomplete. Usually the response from it, transformed into chars, is like "0103141 03 02 00 >" and I use the ">" char in the program as data exchange complete. When the problem occurs I receive fewer bytes from the OBD adapter and without the ">" char, something like "0103141 03 ".

I made a function that resets the HC-05 module and reconnects, but it takes a few seconds and I want my data to come as a continuous flow.

I tried a few methods of debugging, such as changing baud rate of the HC-05, and adding some delays, but I haven't come to a solution.

I believe that the problem might me one of these three:

The cheap ebay clone messing things up.
The HC-05 not sending the complete data.
A problem with my code.

Below I have attached the part of the code that does the sending of the command and reading the response. When the problem occurs, it gets stuck in the while loop because I have no terminating ">" char and I have to break it, call another function that re-establishes communication and so on.

So my question is: has anyone confronted this problem where ELM327 sends incomplete data that cannot be used?

 BTSerial.println("010F1");
 BTSerial.flush();
 delay(10);
  if (BTSerial.available()>0)
      busy = true;
  while(busy = true && inData != 62)
  {
      temp++;
      if (temp>500000){
          resetBT();
          BTSerial.println("ATWS");
          break;
      }
      if (BTSerial.available()>0){
          inData=0;
          inData = BTSerial.read();
          if(inData != 32) {
              buf[i] = inData;
              Serial.print(char(buf[i]));
              i++;
          }

      }

  }
Serial.println();
busy=false;
inData = 0;
i = 0;
memset(buf, 0, sizeof(buf));
temp = 0;


texts:
I have a Wemos D1 board with a OLED display using the u8g2 library.

I am printing my MAC-adress on the serial port & would like to print the same information on the OLED:

#include <ESP8266WiFi.h>
#include <U8g2lib.h>
byte mac[6];
setup(){
  Serial.println(WiFi.macAddress());
  WiFi.macAddress(mac);
  u8g2.drawStr(1,10,WiFi.macAddress());
  u8g2.sendBuffer();
}

This does not work. It prints the MAC-address on the serial port but not on the OLED.

I get: no known conversion for argument 3 from 'String' to 'const char*

How can I print the MAC-information on my oled using the u8g2-library?


texts: Controlling Dynamixel MX24T, MX64T servo wirelessly using Arduino Mega?

texts:
I am planning to control multiple Dynamixel servos (MX28T or MX-64T) wirelessly using an Arduino Mega. Since this servo uses serial communication, I need an additional serial port to interface with XBee module. Although it seems to be very common application controlling these servos wirelessly based on Arduino, I could't find any of them in web. I found the two very well constructed libraries.

https://code.google.com/p/slide-33/downloads/list. This library is for MX28T servo, which is the same servo I am trying to use, but it uses UNO;therefore, I cannot interface with XBee.
The Arduino/Dynamixel Resource Page... This library uses UART1 (serial1) to interface with servo (AX-12) motors. Therefore, I can connect XBee module to UART0. But, the problem is that this library is outdated and not compatible with MX64-T servo anymore.

So my questions are:

Is there any one who has experience in controlling Dynamixel MX24T, MX64T servo series using XBee module simultaneously? If you have experience, please share with me.
Is it possible for Arduino Mega can interface with Xbee module using Serial1 (i.e., RX18 TX19)? If it can, I might be able to use the library1 without any modification.


texts: 'readPulsioximeter' was not declared in this scope

texts:
I am new to Arduino. I am trying to use Pulsioximeter sensor with e-health Platform (http://www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical) on Arduino Uno. Line number 13 is working fine in the example code given in the library and works just fine. But when I try to upload my custom code (setup function definition is given below), I get an error stating 'readPulsioximeter' not defined in this scope. The error doesn't seem obvious to me. Please guide.

Here is the custom code upto setup() function:

#include < eHealth.h >
#include < PinChangeInt.h >
bool configuration = false;
//bool in_it=true;
byte val; // variable to receive data from the serial port
int ledpin = 13; // LED connected to pin 48 (on-board LED)
int A=1;
void setup() {
           pinMode(ledpin, OUTPUT);
           Serial.begin(115200);
           eHealth.initPulsioximeter();
           //Attach the interruptions for using the pulsioximeter.
           PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
           delay(500);
}

 EDIT1:
readPulsioximeter is declared in eHealth.h library which has been included in program. The function has been defined as below in eHealth.cpp file:

    //!******************************************************************************
    //!     Name:   readPulsioximeter()                                             *
    //!     Description: It reads a value from pulsioximeter sensor.                *
    //!     Param : void                                                            *
    //!     Returns: void                                                           *
    //!     Example: readPulsioximeter();                                           *
    //!******************************************************************************
    void eHealthClass::readPulsioximeter(void)
    {
        uint8_t digito[] = {0,0,0,0,0,0};
        uint8_t A = 0;
        uint8_t B = 0;
        uint8_t C = 0;
        uint8_t D = 0;
        uint8_t E = 0;
        uint8_t F = 0;
        uint8_t G = 0;
        for (int i = 0; i<6 ; i++) { // read all the led's of the module
            A = !digitalRead(13);
            B = !digitalRead(12);
            C = !digitalRead(11);
            D = !digitalRead(10);
            E = !digitalRead(9);
            F = !digitalRead(8);
            G = !digitalRead(7);
            digito[i] = segToNumber(A, B, C ,D ,E, F,G);
            delayMicroseconds(2800); //2800 microseconds
        }
            SPO2 = 10 * digito[5] + digito[4];
            BPM  = 100 * digito[2] + 10 * digito[1] + digito[0];
    }


texts: Speed control of BLDC with an integrated controller (Hall out, PWM in)

texts:
I am aiming at precise speed control of this BLDC motor: it has an integrated controller, outputting digital Hall signal (period 20.8ms on oscilloscope, w/o load) and taking PWM as input for speed regulation.
As far as my knowledge goes, this is a task for PID: measure Hall pulses at input, adjust duty cycle of the PWM based on target period/frequency of the Hall output.
The speed should be controlled with <1% error (even less is better).

Is this goal realistic with this particular motor?
How should I measure pulse duration?
Is pulseIn (with interrupts disabled) going to be sufficiently precise? Should I measure lows or highs?
Should I measure several pulses instead (and how)? Or should I accept imprecision in the pulse period and compensate (smooth) it using integral/derivative terms?
Do I need more than 8-bit PWM resolution for this task? (I will use Nano at first, but might switch to Nano Every, which has 10-bit PWM).

Any other comments/suggestions are welcome.


texts: Controlling multiple fans using arduino uno

texts:
I'm kind of new on the field of Arduino. Although I have a question concerning multiple fan connection on 1 arduino PWM pin. The goal is to connect around 8 to 16 fans on 1 arduino  pwm header pin and control their speeds separately using a potentiometer. As I seen it can be achieved by using transistors. The question is are there any limitations on how many fans can I connect and control seperatly using tranzistors? Can I for example use 16 transistors and control 16 fans seperatly ?

Thank you for your answers in advance


texts: GPS only works when I click Reset on Arduino or Reopen Serial Monitor

texts:
I cannot work this out!

My Ublox 7n GPS module will only print data in the serial monitor once when I either click reset on my Arduino Uno or reopen and close my Serial monitor.

So whenever I have the serial monitor open and click reset on my Arduino it quickly spits out all the data on it and then stops, same when I open the serial monitor after being closed.

Here is my code:

#include "TinyGPS++.h"
void displayInfo();
const unsigned long PUBLISH_PERIOD = 1000;
double latitude = 0, longitude = 0;
TinyGPSPlus gps;
unsigned long lastPublish = 0;

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

void loop()
{

    while (Serial.available() > 0) {

      if (gps.encode(Serial.read())) {
        displayInfo();
     }
    }
  delay(1000);
  Serial.println("new");
}

void displayInfo()
{
  if (millis() - lastPublish >= PUBLISH_PERIOD) {
    lastPublish = millis();
    char buf[128];
    delay(1000);

    if (gps.location.isValid()) {
      snprintf(buf, sizeof(buf), "%lf,%lf", gps.location.lat(), gps.location.lng());
      //  Serial.println(buf);
     latitude = gps.location.lat();
     longitude = gps.location.lng();
     Serial.println(gps.location.lat());
     Serial.println(gps.location.lng());
     Serial.println(latitude, 8);
     Serial.println(longitude, 8);
      }
  else {
    Serial.println("no location");
  }
}
}

I've attached an image of my serial monitor, the gps data came through when I closed and reopened it.