texts: What could cause AdC Reading only to get stucked?

texts:
I am doing a Solar water heating contrôler with arduino.
I have had a freeze of the AdC value read (ntc probe that read Solar panels) that remained at -1.75degc. this was confirmed by the serial data sent an recorded (using raspberry and Time series database) but also the direct Reading on the LCD (16x2). After rebooting Arduino everything get back normally.
Additionnel strange thing is that the water tank ds18b20 temperature sensor serial data value showed a huge spike 1e4... That lasts less than 1 second (which Can not happen as the sensor max value is 125 deg c from this numerical sensor.). After that spike, the adc recorded value remained Frozen. The other ds28b20 and LCD menu navigation and display were ok...
Could that be related to EMI?
To SRAM overflow? Even if the rest of the program seems to work?
What could enables me to discriminates between those issues?
It seems it happened arround 2 days after the Arduino was rebooted.
Description of set up:
I am using a standalone atmega 328 with polulu programmer. 8mhz internal crystal. Everything places on veroboard (main). Then a child veroboard holds the various resistors (Pullup, pulldown) for the input signals. Another child veroboard holds the outputs (pwm pump speed driver), optocoupler for pump Relay.
The supply is a meanwell din rail 5v ac-dc concerter.
I places decoupling caps arround atmega 328, diode+ pull up resistor + cap on reset Line as i had resets regularly (they are gone now).
The pump Relay is on a separate 24v supply. Grounds are separrated from Arduino with this 24v circuit (that incluses flyback diode). But grounds are common to main and 2 children veroboards. The ntc Solar panel probe wire is twisted rj45 cat6. It is shielded and shielding is connected to the atmega grounds.
My program is non blocking type with use of millis and state machines. During developpent I checked the Time operation of the program that was running fast (no delay).
The main structure is quite straightsforward. See bellow commented:
//Get Button state and debounce
buttonLeft.launchSM();
buttonRight.launchSM();
buttonDown.launchSM();
buttonUp.launchSM();

//Menu(uses menubackend library)
menuNavigationBehavior(); // ie detect action from button pressed.Should be executed very rapidely... (less than 10 ms).
EditingVarInMenu(); // changing variables in Menu requiring speed loop (set parameters for example)

//Getting Temperature from panel1, 5 for 5 averaged values
//every 20 ms ie 20 * 5 we have a temperatuure every 100 ms.
TemperaturePanel1(5,20,Tpanel1);

//Getting Temperature from one wire. Time between fetch and return of 100 ms.
getOneWireTemp ();

//CONTROLLER---------------------------------------------------------------
//System Control Logic updated at Time loop
// Controller logic state machine execution
switch (ControllerMainState)
    {
        case CONTROL_MANUAL:
          ManualStateActions();
          break;

        case CONTROL_AUTO:
          AutoStateActions();
          break;

        case CONTROL_ERROR:
          ErrorStateActions();
          break;
    }

    //MENU DISPLAY_____________________________

    if( millis() - timer_50_ms > 200) //
         {
              timer_50_ms = timer_50_ms+200;
              displayMenu(); // change the display. Can be done less often ie every 200 ms
          }


texts: code error- Real Time Clock program-DS3231 RTC module

texts:
I'am a NEW-B with an ELEGOO mega 2560 starter kit.The program code came from their disc.The verifying error message for the declaration: RTCDateTime dt; is

RTCDateTime' does mot name a type

exit status 1

'RTCDateTime'does not name a type

I can not determine what this means or how to correct.
HELP,Dick


texts: What is commonly done to stop a servo after reaching desired position?

texts:
When I started Arduino, I did not expect that everything must be contained in an infinite loop. I thought I could just write something like: motor start -> motor stop. But in actuality, what I get is motor start -> motor stop -> motor start -> ... forever and ever.

What is commonly done to stop a servo after it is in a desired position? Do I use servo.write(desired position) to keep it from turning? Do I detach the output wire?

What are some of the risks involved?


texts: I get the following error when I typed the below code. " Stray'\302" in the programme .I tried to sort it but failed

texts:
#include <Keypad.h>

#include<LiquidCrystal.h>

#include<EEPROM.h>

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

char password[4];

char initial_password[4],new_password[4];

int i=0;

int relay_pin = 10;

char key_pressed=0;

const byte rows = 4;

const byte columns = 4;

char hexaKeys[rows][columns] = {

{'1','2','3','A'},

{'4','5','6','B'},

{'7','8','9','C'},

{'*','0','#','D'}

};

byte row_pins[rows] = {A0,A1,A2,A3};

byte column_pins[columns] = {A4,A5,3,2};

Keypad keypad_key = Keypad( makeKeymap(hexaKeys), row_pins, column_pins, rows, columns);

void setup()

{

  pinMode(relay_pin, OUTPUT);

  liquid_crystal_display.begin(16,2);

  liquid_crystal_display.print(" DIYhacking.com");

  liquid_crystal_display.setCursor(0,1);

  liquid_crystal_display.print("Electronic Lock ");

  delay(2000);

  liquid_crystal_display.clear();

  liquid_crystal_display.print("Enter Password");

  liquid_crystal_display.setCursor(0,1);

  initialpassword();

}

void loop()

{

  digitalWrite(relay_pin, HIGH);

  key_pressed = keypad_key.getKey();

  if(key_pressed=='#')

    change();

  if (key_pressed)

  {

    password[i++]=key_pressed;

    liquid_crystal_display.print(key_pressed);

      }

  if(i==4)

  {

    delay(200);

    for(int j=0;j<4;j++)

      initial_password[j]=EEPROM.read(j);

    if(!(strncmp(password, initial_password,4)))

    {

      liquid_crystal_display.clear();

      liquid_crystal_display.print("Pass Accepted");

      digitalWrite(relay_pin, LOW);

      delay(2000);

      liquid_crystal_display.setCursor(0,1);

      liquid_crystal_display.print("Pres # to change");

      delay(2000);

      liquid_crystal_display.clear();

      liquid_crystal_display.print("Enter Password:");

      liquid_crystal_display.setCursor(0,1);

      i=0;

    }

    else

    {

      digitalWrite(relay_pin, HIGH);

      liquid_crystal_display.clear();

      liquid_crystal_display.print("Wrong Password");

      liquid_crystal_display.setCursor(0,1);

      liquid_crystal_display.print("Pres # to Change");

      delay(2000);

      liquid_crystal_display.clear();

      liquid_crystal_display.print("Enter Password");

      liquid_crystal_display.setCursor(0,1);

      i=0;

    }

  }

}

void change()

{

  int j=0;

  liquid_crystal_display.clear();

  liquid_crystal_display.print("Current Password");

  liquid_crystal_display.setCursor(0,1);

  while(j<4)

  {

    char key=keypad_key.getKey();

    if(key)

    {

      new_password[j++]=key;

      liquid_crystal_display.print(key);

    }

    key=0;

  }

  delay(500);

  if((strncmp(new_password, initial_password, 4)))

  {

    liquid_crystal_display.clear();

    liquid_crystal_display.print("Wrong Password");

    liquid_crystal_display.setCursor(0,1);

    liquid_crystal_display.print("Try Again");

    delay(1000);

  }

  else

  {

    j=0;

    liquid_crystal_display.clear();

    liquid_crystal_display.print("New Password:");

    liquid_crystal_display.setCursor(0,1);

    while(j<4)

    {

      char key=keypad_key.getKey();

      if(key)

      {

        initial_password[j]=key;

        liquid_crystal_display.print(key);

        EEPROM.write(j,key);

        j++;

      }

    }

    liquid_crystal_display.print("Pass Changed");

    delay(1000);

  }

  liquid_crystal_display.clear();

  liquid_crystal_display.print("Enter Password");

  liquid_crystal_display.setCursor(0,1);

  key_pressed=0;

}

void initialpassword(){

  for(int j=0;j<4;j++)

    EEPROM.write(j, j+49);

  for(int j=0;j<4;j++)

    initial_password[j]=EEPROM.read(j);

}


texts: I'm pretty sure I fried my Arduino Uno. Given my setup, what caused it to be fried? (I can't identify the short)

texts:
I was trying to drive a Nema 17 stepper motor using an arduino uno and an A4988 driver. I had it wired up according to this instructable (http://www.instructables.com/id/Drive-a-Stepper-Motor-with-an-Arduino-and-a-A4988-/) at step 2 without the motor power supply wired to the bread board yet. ALSO, I hadn't wired the sleep to reset yet (I just didn't read directions carefully). The board was connected to my computer via USB and I had uploaded the sketch on the instructable to it.

Then, because I misunderstood the directions, I plugged my 12V 8A power supply into the power input on the arduino. All of the sudden, my computer turned off. My computer is fine after restarting, but now the arduino isn't recognized at all by the computer when I plug it in.

Given this information, I am pretty sure that my arduino is fried. However, I can't understand why plugging in the power supply to the power input, which has a voltage regulator, would cause the board to fry.


texts: Unable to power an Arduino Pro Mini through the RAW pin

texts: I've recently bought an Arduino Pro Mini, the 3.3V and 8MHz version. The first time I powered it, using the VCC pin, all worked. But, as soon as I attempt using the RAW pin instead, nothing lights up... Is my regulator broken ? Or is this a typical issue ?


texts: Generate & Display QR using Nodemcu on TFT Display ST7789 240*240

texts:
I have NodeMCU & ST7789 TFT display. I want to generate QR Code of any dynamic input and display it on my TFT display. Not able to find any suitable reference. All Standard QR code libraries only work for Arduino & not for NodeMcu, board not supported for them. Can someone please help ?

Libraries Tried :
https://github.com/yoprogramo/ESP_QRcode
https://github.com/anunpanya/ESP8266_QRcode
https://github.com/ricmoo/qrcode
https://github.com/onelife/rtt-qrcode


texts: Does LabVIEW Linx affect the communication speed with Arduino?

texts:
I am using LabVIEW to connect to Arduino Mega. I control a logic gate to switch the current On/Off and at the same time there is an I2C connection with a sensor. It came to my attention that the sensor time resolution is very low and I cannot get enough data points from the sensor (I know that the sensor is capable of much better resolutions). My question, is this a problem inherent to LabVIEW and Linx module or my program in LabVIEW? Should I turn to coding with Arduino programming language or C?
note! My reason for using LabVIEW is that I need to sync timing of data aqcuisition with another device which is connected through another VISA port.


texts: What are a few good ways to connect multiple I2C busses?

texts:
I have an issue with a project. I have a backplane with an Atmega328P based microcontroller controlling an I2C bus with multiple peripheral devices. One such peripheral is a removable card with another Atmega328P based microcontroller as the peripheral. I have a TCA4311ADR I2C hotswap buffer on the backplane connected to the port that connects to the card. The card is supposed to be a peripheral device that sends processed data from a sensor to the backplane.
Here’s my issue: one of the sensors I intend to use on the card is an I2C breakout board. To control it, the microcontroller on the card needs to act as a controller, but it also needs to be a peripheral to communicate with the backplane controller. Every time I try to make this work and the card tries to communicate with the sensor, it tries to start a new I2C bus and everything starts glitching.
I’ve tried a few options. Software used to turn normal digital pins into I2C pins didn’t work since the libraries don’t seem compatible. I can’t seem to get the card peripheral to wait until the controller starts the bus before trying to control the sensor to avoid a conflict.
I had an idea to use an I2C multiplexer like the TCA9543A to create two busses but I don’t know if that would work. I also don’t wanna just use SPI or Serial to connect the microcontrollers cause I’d have to undo months of work on coding and custom PCBs. Also using Serial would complicate the connection to the computer and using SPI wouldn’t work if I use an SPI sensor breakout later.
Is there any other way to make this system work?


texts: BLE HM10 - Set Password - Android Pairing Problem

texts:
I have developed an application on Android, which connects to a Bluetooth HM10, launches commands, and turns LEDs on and off through my Arduino. All of this works properly.
So, I want to make Bluetooth secure, so that nobody can connect to it, and keep it busy and I can't connect myself.
To do this, from my Serial Monitor I execute the corresponding configuration commands, but I never get it to link correctly on my Android.
I have tried many options, to no avail:
OPTION 1)

AT+ROLE? = Ok+Get:0 (Slave or Periphe)
AT+TYPE2 = Ok+Set:2 (Auth with PIN)
AT+PASS123456
AT+RESET

OPTION 2)

AT+ROLE? = Ok+Get:0 (Slave or Periphe)
AT+TYPE3 = Ok+Set:3 (Auth and bond)
AT+PASS123456
AT+RESET

In both cases (and more failed tests), I see the BLE device on my Android Bluetooth.
I give it to connect and the window to enter the password pops up.
I introduce 123456
And it always tells me that it could not be linked.
Any ideas for why?
Thank you.


texts: How to learn enough C++ to program Arduino?

texts:
I am an experienced web developer, but my C++ skills are very basic. I struggle with the concepts because it is so different from something like Javascript (which I already know). I do not have a lot of time to learn C++, and I only need to know enough to play with Arduinos.

Are there any good resources out there for learning C++ that is specifically geared towards Arduino programming, and is there anything interactive like Codecademy?


texts:
I've got an SD card and speaker hooked up to my nano and I can play mono audio files easily. My question is, is it possible to control the speed of a motor using the pwm output to the speaker? I tried just hooking the motor in where the speaker was, but that produced no noticeable variations in speed.

Alternatively, is it possible to analyse the wav file on the nano and control the motor that way? (i.e. motor speed is dependant on volume at a given time)

Thanks


texts: SPI communication between two Ethernet Shields (W5100)

texts:
I am a newbie to the world of IoT, I want to ask...

Is it possible to connect two Ethernet shields with SPI? And if yes, how can I codes them?

I have reference from http://www.gammon.com.au/spi and I've tried SPI communication between two Arduino Unos send & receive any data type..

Now.. I want to put Ethernet Shields to each Arduino Unos, and I want to make them can communicate via SPI, It's like they can send & receive data type (ping IP address each other). If that scenario can running well, is it possible I can ping Shield one and Shield two?
(without router/switch, for this IoT research I still used local network, each Arduino w/ Shield plug to each laptop via RJ45 & USB port of course)

Topology:

Laptop A <===> Arduino Uno w/ Ethernet Shield <---> Arduino Uno w/ Ethernet Shield <===> Laptop B.

Note:

<===> = RJ45
<---> = Wire jumper (SPI or Pin 13 12 11 10, GND)

Sorry for my bad language, I didn't speak English well..

Can anyone help me?
Thank you,

H.


texts:
I am making a shield for Arduino Due. It will be a simple board with ribbon connectors for taking a variety of interfaces to external boards. It will be Open Source hardware.

I have been searching for about 3 weeks for a drawing or layout that will allow me to locate, mechanically the ICSP connector. I have downloaded about 100 drawings and none of them seem to locate it.

I downloaded KiCad and installed it on Win7 thinking that I could find the needed info there from existing KiCad shields. I can't get KiCad to "do anything" once it opens.

I downloaded free Eagle and installed it on Win7 thinking that I could find the needed info there from existing Eagle shields or the Eagle files for the Due board itself. When I try to run Eagle, it instantly crashes.

I have even visited and joined EasyEda and looked at shield projects there, but I do not find any that locate the ICSP connector.

The "Bombsightings" jpg that I got from this forum is great BUT, no ICSP location data.

Any help will be much appreciated !


texts: Arduino Library to make http post request with bearer authentication

texts:
I want to make an Http Post request with Bearer Authentication to my api using my Arduino Mkr Wifi 1010, but I couldn't find the appropriate library to do something like this (code generated with one made with Postman):
    POST /api/v1/rilevamento/transaction/commit HTTP/1.1
Host: www.....:8082
Authorization: Bearer eyJhb.......
Content-Type: application/json
Content-Length: 233

{
    "id": 0,
    "dispositivo": "sesto",
    "nomeutente": "MyName",
    "cognomeutente": "MySurname",
    "mailutente": "name@email.it",
    "data": "2020-11-23T09:23:03.142+00:00",
    "temperatura": 37.5
}

Can you tell me where to find this library? I tried WifiNiNa httpClient, ArduinoHttpClient, HTTPClient and other but I couldn't  get any response or even enter in the method of my api on debug.


texts: Sim800l gsm module cannot connect gprs data

texts:
I am a rookie to arduino. I am trying to access MQTT server using Sim800l coreboard GSM module with Adafruit Fona/Tinygsm library but failed.So I decided to check http GET/POST request with AT command first.In AT commands all the basic commands following www.exploreembedded.com/wiki/Setting_up_GPRS_with_SIM800L  works fine  but whenever I make a GET request by "AT+CIPSTART=" module restart itself.I also tried seeduino library GPRS_HTTP example, it gives me "error:CIPSTART" and restarts module.Though this code worked one time only,this is the code

#include <gprs.h>
#include <SoftwareSerial.h>

char http_cmd[] = "GET /media/uploads/mbed_official/hello.txt
HTTP/1.0\r\n\r\n";
char buffer[512];

GPRS gprs;

void setup() {
Serial.begin(9600);
while(!Serial);
Serial.println("GPRS - HTTP Connection Test...");
gprs.preInit();
while(0 != gprs.init()) {
 delay(1000);
 Serial.println("init error");
}
while(!gprs.join("gpinternet")) {  //change "cmnet" to your own APN
  Serial.println("gprs join network error");
  delay(2000);
}
// successful DHCP
Serial.print("IP Address is ");
Serial.println(gprs.getIPAddress());

Serial.println("Init success, start to connect mbed.org...");

if(0 == gprs.connectTCP("mbed.org", 80)) {
  Serial.println("connect mbed.org success");
}else{
  Serial.println("connect error");
  while(1);
}

Serial.println("waiting to fetch...");
if(0 == gprs.sendTCPData(http_cmd))
{
gprs.serialDebug();
}

//  gprs.closeTCP();
//  gprs.shutTCP();
//  Serial.println("close");
}

void loop() {

}

also tried this commands and module got restarted after AT+HTTPACTION=0 this last command

module power and sim configure are fine as far I know,please help me find out what am I doing wrong?Sorry for making this long.please ask me if I couldn't make the question clear.TIA


texts: Send data using Arduino GSM shield GET/POST/PUT?

texts:
I am trying to modifiy the Arduino GSM library Xively example to geeknesia.com. The serial said "successconnecting.." but I didn't get any value change in the website. Did I make a mistake with this code?

//Project Name Test sensor
#include <GSM.h>

#define PINNUMBER ""

//APIkey untuk Geeknesia
#define APIKEY  "c3ce75cc23386ca4ca663c0ed11653c5"
#define GPRS_APN       "xlunlimited"
#define GPRS_LOGIN     ""
#define GPRS_PASSWORD  ""

GSMClient client;
GPRS gprs;
GSM gsmAccess;
GSMServer server(80);

char IPserver[]="geeknesia.com";
unsigned long lastConnectionTime = 0;
boolean lastConnected = false;
const unsigned long postingInterval = 10*1000;
int ldr1;
char ldr1_ar[10];

void setup() {
   Serial.begin(9600);
   boolean notConnected = true;
   Serial.println("try to connect...");
   while (notConnected) {
    if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &
        (gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY))
      notConnected = false;
    else {
      Serial.println("can't connect");
      delay(1000);
    }
  }
  Serial.println("connected");
}

void sendData(int thisData) {
  if (client.connect(IPserver, 80)) {
    Serial.println("connecting...");
    client.print("GET /api/data?api_key=c3ce75cc23386ca4ca663c******&attributes={");
    client.print("\"ldr1\":" + String(ldr1));
    client.print("}");
    client.print("\r\n\r\n");
    client.print("Content-Length: ");
    int thisLength = 8 + getLength(thisData);
    client.println(thisLength);
    client.println("Connection: close");
    client.println();
    //client.print("cahaya,");
    client.println(thisData);
  } else {
    Serial.println("connection failed");
    Serial.println();
    Serial.println("disconnecting.");
    client.stop();
  }
  lastConnectionTime = millis();
}

int getLength(int someValue) {
  int digits = 1;
  int dividend = someValue /10;
  while (dividend > 0) {
    dividend = dividend /10;
    digits++;
  }
  return digits;
}

void loop() {
  ldr1 = analogRead(A0);
  //sendData(ldr1);
  if (client.available()) {
     char c = client.read();
     Serial.print(c);
  }
  if (!client.connected() && lastConnected) {
    client.stop();
  }
  if(!client.connected() && ((millis() - lastConnectionTime) > postingInterval)) {
    sendData(ldr1);
  }
  lastConnected = client.connected();
}


texts: For my apartment, I need to check when intercom is ringing and call an API in that case. I was thinking about using an AC input / DC output relay, since the buzzer signal is an AC signal. Is there an equivalent pre-built component similar to this?


texts: Sending data over TCP connection in one piece

texts:
I'm trying to send short strings via Java client to Arduino server and vice versa. Sending data to client goes fine, but when I try to send data to arduino it cuts the string into bytes and then sends the first letter.  Will the following work?

for(int i = 0; i < data.length(); i++)

Even if it can be sent as characters I want to send it in one piece, because strings are very short so there should be no problems with length.

EDIT: Alright, I read client.read() documentation, so the problem is at arduino.

This is my java code:

public class TCP {
static Socket clientSocket;

public static void main(String args[]) throws Exception {
    clientSocket = new Socket("10.10.10.57", 5000);
    sendToServer("HAI THERE\n");
    String msg = getFromServer();
    System.out.println(msg);
    close();
}

static void sendToServer(String msg) throws Exception {
    //create output stream attached to socket
    PrintWriter outToServer = new PrintWriter(new OutputStreamWriter(clientSocket.getOutputStream()));
    //send msg to server
    outToServer.print(msg + '\n');
    outToServer.flush();
}

static String getFromServer() throws Exception{
    //create input stream attached to socket
    InputStreamReader isr = new InputStreamReader(clientSocket.getInputStream());
    BufferedReader inFromServer = new BufferedReader(isr);
    //read line from server
    String res = inFromServer.readLine(); // if connection closes on server end, this throws java.net.SocketException
    return res;
}

static void close() throws IOException{
    clientSocket.close();
}
}

This code sends only one byte at the same time.It might be problem in my arduino code, since I read it with

char c = client.read()

One more thing. If there is any java master, I would like to know what to do with exceptions. How should I handle disconnected socket, failed connection to server, and so forth?


texts:
I have this method:

void getWeatherData() {
    String resp = "";

    Process p;
    p.begin("python2.7");
    p.addParameter("/root/weather.py");
    p.run();

    while (p.available() > 0) {
        char c = p.read();
        resp = resp + c;
    }

    Serial.print(resp);
    Serial.flush();
}

In the serial monitor, I see the string 70.7|45|1030.29|06:05|20:04|04 May 2015 22:24. The delimiter here is the pipe. Now, the parts I take a send them to methods that puts the values on the TFT screen.

However, I fail to understand how to split this long string into individual parts.

Can somebody help?

Thanks

EC


texts: HTTP request is not being executed in Arduino script for sending sensor data to Thingspeak cloud

texts:
I am trying to send the data from DHT sensor (temperature and humidity on 2 channels of Thingspeak cloud server) and firstly display them on Thingspeak cloud. Afterwards I will need to get those data from the cloud and use them with Python in order to make some calculations. Sensor data is sent via SIM900 GSM module.

I succeeded to send some constant value to Thingspeak by executing AT commands, one by one, which I put later in this code: https://pastebin.com/4bP6hgk7 EDIT: Here is the code:

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

#define DHTPIN 2
#define DHTTYPE DHT11

// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);

// Create global varibales to store temperature and humidity
float t; // temperature in celcius
float f; // temperature in fahrenheit
float h; // humidity

SoftwareSerial gsm(7, 8);

void setup() {
  // put your setup code here, to run once:
  dht.begin();

  gsm.begin(9600);
  Serial.begin(9600);

  gsm.println("AT+IPR=9600");
  delay(1000);

  gsm.println("AT+CGATT=1");
  delay(1000);

  gsm.println("AT+SAPBR=1,1");
delay(1000);

  ShowSerialData();

  gsm.println("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\"");
  delay(1000);

  ShowSerialData();

  gsm.println("AT+SAPBR=3,1,\"APN\",\"prepaidnet\"");
  delay(1000);

  ShowSerialData();

  gsm.println("AT+SAPBR=3,1,\"USER\",\"mts\"");
  delay(1000);

  ShowSerialData();

  gsm.println("AT+SAPBR=3,1,\"PWD\",\"064\"");
  delay(1000);

  ShowSerialData();

  gsm.println("AT+SAPBR=1,1");
  delay(1000);

  ShowSerialData();

  gsm.println("AT+SAPBR=2,1");
  delay(1000);

   ShowSerialData();

   gsm.println("AT+HTTPTERM");
  delay(1000);

   ShowSerialData();

  gsm.println("AT+HTTPINIT");
  delay(2000);

  ShowSerialData();

  gsm.println("AT+HTTPPARA=\"CID\",1");
  delay(3000);

  ShowSerialData();

}

void loop() {
  // put your main code here, to run repeatedly:
  while(gsm.available()) {
    Serial.write(gsm.read());
  }
  if(Serial.available()) {
    gsm.write(Serial.read());
}

 t=readTemp();
h=readHum();

gsm.print("AT+HTTPPARA=\"URL\",\"https://api.thingspeak.com/update?api_key=Z1Q5633A4S1GHIHU&field1=26");
//gsm.print(t);
//gsm.println();
delay(5000);
//gsm.println((char)26);

ShowSerialData();

delay(1000);
gsm.println("AT+HTTPPARA=\"REDIR\",1");
delay(3000);
gsm.println("AT+HTTPSSL=1");
delay(3000);
gsm.println("AT+HTTPACTION=0");  /* Start POST session */
delay(5000);
gsm.println("AT+HTTPREAD");
delay(3000);
gsm.println("AT+HTTPTERM"); /* Terminate HTTP service */
delay(5000);
gsm.println("AT+SAPBR=0,1");
delay(3000);
ShowSerialData();

}

float readTemp() {
  // Read temperature as Celsius
  t = dht.readTemperature();
  //Read humidity
  h = dht.readHumidity();

  // Compute temperature values in Celcius
  t = dht.computeHeatIndex(t,h,false);

  // Check if any reads failed and exit early (to try again).
  if (isnan(t)) {
    Serial.println("Failed to read temp from DHT sensor!");
    return 1;
  }

  return t;
}

float readHum() {
  //Read humidity
  h = dht.readHumidity();
  // Read temperature as Celsius
  t = dht.readTemperature();

  // Compute temperature values in Celcius
  t = dht.computeHeatIndex(t,h,false);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h)) {
    Serial.println("Failed to read hum from DHT sensor!");
    return 1;
  }

  return h;
}

void ShowSerialData()
{
  while(gsm.available()!=0)
    Serial.write(gsm.read());
    if(Serial.available()) {
    gsm.write(Serial.read());
  }
}

The problem is that not the whole script is executed - AT+HTTPPARA command with the parameter "URL" and the URL where the data should be sent is not being executed. I have read many answers but could't find the answer for this. Could anybody help with this issue? Thanks in advance!


texts: Why Won't my Serial Read value stay the same

texts:
I am trying to write to serial to control the brightness of an LED. When I initially type in a value such as '50' or '100', the LED lights up, but then the 'ppm' value drops down to '10' and just stays there (regardless of what I enter in initially. Any idea why this is occurring?

int ledpin1 = 3;
int pwm = 0;

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  pinMode(ledpin1, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // reads input to serial monitor
  if (Serial.available() > 0) {
    pwm = Serial.read();
  }

  analogWrite(ledpin1, pwm);
  Serial.print("PWM value is: ");
  Serial.println(pwm);
  delay(1000);

}


texts: Is it possible to connect Longan Nano with WS2815 LED stripde?

texts:
I have a very interesting interface card - Longan Nano and a LED stripe WS2815 (12V). As far as I understand, I need to connect to DI pin of the LED stripe some pin from SPI output of the card. As the SPI connector has 6 pins as follows:

MISO - Master in / Slave Out
VCC
SCK, shift clock
MOSI - master Out / Slave In
SS - slave select
GND

and the LED stripe gets SPI data commands...
Am I right that I need to use a Master Out / MOSI pin (i.e. B5 or A7 on the board) to connect with the LED Stripe DI pin?
Thank you for any advice, Vlad.


texts: Serial.println for pointers to the byte datatype behaves unexpectedly

texts:
byte subkeys[16][48/8];

for (size_t address = 0; address < 16*6; address++)
    Serial.println( (byte) *(subkeys + address) );

Why won't the compiler handle this? It tells me

  cast from 'byte* {aka unsigned char*}' to 'byte {aka unsigned char}' loses precision [-fpermissive]

If I omit the (byte) part, it tells me

  call of overloaded 'println(byte [6])' is ambiguous

I have no idea what's happening.


texts: CNC Y-axis stepper moving forward but not in opposite direction

texts:
I'm building an CNC mill with an Arduino UNO with a CNC Shield V3. But I have a problem with the Y motor direction. It only moves in one way while the X motor is moving both ways. When I just installed everything it worked, but after a view tries it doesn't anymore. I viewed multiple topics on this problem but nothing is working.

I tried to switch the stepper drives but that didn't make a difference.

Switched the stepper motors and then the x motor moved in one way so it isn't the stepper motor.

Tried cloning the Y controller to the 4th connection. Also didn't work.

Tried multiple GRBL HEX files, all the same.

I also tried multiple gcode senders but is just doesn't make a difference.

Is there anything else that I can try to help this problem? Or shall I order an new shield to test if this shield is broken.


texts: Using MMA8451 accelerometer to count steps

texts:
I'm trying to use an Adafruit MMA8451 accelerometer to create a pedometer-type device that counts steps. I'd like to initiate a counter that says "if the x-axis readout is > some threshold, add 1 to the counter" so that once the counter reaches a certain point, I'll be able to trigger a separate event (like an LED turning on). I'm an Arduino beginner, and would appreciate any pointers in the right direction as I work through this.

I'm using the Sparkfun Redboard and the Adafruit MMA8451, and wrote a loop to check whether the x-axis readout was over 5. If it's over 5, I want it to add 1 to the accumulator. However, it's accumulating 1 each readout regardless of what the 'x' reading actually is. Can anyone tell what I'm doing wrong? A nudge in the right direction would be much appreciated.

Code is here:

/**************************************************************************/
int lastStepCount = 0;
int accum = 0;

#include <Wire.h>
#include <Adafruit_MMA8451.h>
#include <Adafruit_Sensor.h>

Adafruit_MMA8451 mma = Adafruit_MMA8451();

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

  Serial.println("Adafruit MMA8451 test!");

  if (! mma.begin()) {
    Serial.println("Couldnt start");
    while (1);
  }
  Serial.println("MMA8451 found!");

  mma.setRange(MMA8451_RANGE_2_G);

  Serial.print("Range = "); Serial.print(2 << mma.getRange());
  Serial.println("G");

}

void loop() {
  // Read the 'raw' data in 14-bit counts
  mma.read();
  Serial.print("X:\t"); Serial.print(mma.x);
  Serial.print("\tY:\t"); Serial.print(mma.y);
  Serial.print("\tZ:\t"); Serial.print(mma.z);
  Serial.println();

  /* Get a new sensor event */
  sensors_event_t event;
  mma.getEvent(&event);

  /* Display the results (acceleration is measured in m/s^2) */
  Serial.print("X: \t"); Serial.print(event.acceleration.x); Serial.print("\t");
  Serial.print("Y: \t"); Serial.print(event.acceleration.y); Serial.print("\t");
  Serial.print("Z: \t"); Serial.print(event.acceleration.z); Serial.print("\t");
  Serial.println("m/s^2 ");

  /* initiate for loop to count movement— this is the piece I'm having trouble with */
  if (event.acceleration.x >= 5);
    accum = accum + 1;
  Serial.print("X Counter: "); Serial.print(accum);

  /* Get the orientation of the sensor */
  uint8_t o = mma.getOrientation();

  switch (o) {
    case MMA8451_PL_PUF:
      Serial.println("Portrait Up Front");
      break;
    case MMA8451_PL_PUB:
      Serial.println("Portrait Up Back");
      break;
    case MMA8451_PL_PDF:
      Serial.println("Portrait Down Front");
      break;
    case MMA8451_PL_PDB:
      Serial.println("Portrait Down Back");
      break;
    case MMA8451_PL_LRF:
      Serial.println("Landscape Right Front");
      break;
    case MMA8451_PL_LRB:
      Serial.println("Landscape Right Back");
      break;
    case MMA8451_PL_LLF:
      Serial.println("Landscape Left Front");
      break;
    case MMA8451_PL_LLB:
      Serial.println("Landscape Left Back");
      break;
  }
  Serial.println();
  delay(500);

}

**Update: the output I'm getting is as follows. The "X Counter" accumulates even when the x-reading is well below 5...not sure what's going on:

X:  1Adafruit MMA8451 test!
MMA8451 found!
Range = 2G
X:  144 Y:  50  Z:  4052
X:  0.34    Y:  0.11    Z:  9.66    m/s^2
X Counter: 1Portrait Up Front

X:  138 Y:  62  Z:  4052
X:  0.34    Y:  0.11    Z:  9.70    m/s^2
X Counter: 2Portrait Up Front

X:  0   Y:  48  Z:  4040
X:  -0.02   Y:  0.11    Z:  9.67    m/s^2
X Counter: 3Portrait Up Front

X:  -780    Y:  106 Z:  3814
X:  -1.80   Y:  0.25    Z:  9.11    m/s^2
X Counter: 4Portrait Up Front

X:  -510    Y:  106 Z:  4008
X:  -1.46   Y:  0.20    Z:  9.68    m/s^2


texts: How to connect Big Dome Button with arduino

texts: I am quite new to arduino and for a project I want to use big dome button which when pressed it will count how many times has been pressed.It is using 12 volts.The button is this https://www.sparkfun.com/products/9181


texts: Help using uint32_t? Trying to feed arduino serial from raspberry pi. Any help is very very much appreciated

texts:
So I don't know C so I'm just trying to get some very very basic code running on my arduino to send it commands over serial.
I'm feeding serial into buf
irsend.sendNEC(0x210704FB, 32)
this works but I need to read from buf instead of hardcoding for one code.
irsend.sendNEC(buf, 32) won't compile but irsend.sendNEC((uint32_t) buf, 32) will. It just doesn't do anything.
When I use
serial.print((uint32_t) buf, 32);
it prints just seemingly random letters?
I'm trying to just feed it a serial code with a language I know a little better. I can send the hex code over serial with python but I don't know the first thing about C. I don't understand why I can't just feed it a variable and have it read it as is.
here's my code
#include <IRremote.h>

char buf[80];

int readline(int readch, char *buffer, int len) {
  static int pos = 0;
  int rpos;

  if (readch > 0) {
    switch (readch) {
      case '\r': // Ignore CR
        break;
      case '\n': // Return on new-line
        rpos = pos;
        pos = 0; // Reset position index ready for next time
        return rpos;
      default:
        if (pos < len-1) {
          buffer[pos++] = readch;
          buffer[pos] = 0;
        }
    }
  }
  return 0;
}

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

IRsend irsend;

void loop() {
  if (readline(Serial.read(), buf, 80) > 0) {
    //tried to set up code to show what the arduino received and tried ways to send
    //Serial.print("You entered: >");
    //Serial.print(buf);
    //Serial.println("<");
    //doesn't seem to do anything irsend.sendNEC((uint32_t) buf, 32);
    //works but only for this one button irsend.sendNEC(0x210704FB, 32);
    //want to use irsend.sendNEC(buf, 32);
    //me trying to figure out what irsend is being fed through buf Serial.print((uint32_t) buf, 32);

  }
}


texts: What variables to declare for controlling a motor with high power motor controller

texts:
I was getting started with programming a motor controller with the Arduino Uno, in this case it's a mega motor shield (the motor driver shield I'm using).
The problem I have doing this is that I'm not sure what variables to use for the motor which is connected to two outputs labeled MA and MB.  I used motorValue to set the speed previously and used motorPin for writing the speed with the Arduino and a breadboard, but I'm not sure what to use in place of that for the motor being connected to the driver shield outputs.


texts: How to use SoftwareSerial.Write without blocking if buffer is full? Serial.write blocks if the buffer is full. So I need to check Serial.availableforwrite before calling write to prevent blocking. But there is no SoftwareSerial.availableforwrite. How can I use SoftwareSerial.Write without blocking?


texts: How to choose SPI type used by RF24 library from application?

texts:
I am developing a device with Ethernet shield (with Wiznet W5100) and NRF24L01+. I need to use Soft SPI due to a bug in the Wiznet chip. Next I am developing a different device with NRF24L01+ only. I want to use hardware SPI (besides other things it already contains a socket for NRF24L01+ connected to the default Arduino SPI pins).

It is very inconvenient to enable/disable #define SOFTSPI in RF24_config.h every time I want to work on the other device.

Is there a way how to choose the SPI type used by RF24 library in the application?

My current solution is to make a copy of RF24 to RF24_SoftSpi and RF24Network to RF24Network_SoftSpi. I enabled SOFTSPI in “_SoftSpi” versions (+ renamed all files, fixed includes and #ifndef statements in headers to avoid ambiguous errors).

Then in an application I just include RF24_SoftSpi instead of RF24 and RF24Network_SoftSpi instead of RF24Network to use software SPI.

With this workaround it is difficult to make updates to “_SoftSpi” libraries when a new feature is released.

Do you know of any better solution?


texts:
I just bought an Arduino Nano v3.0 (compatible? +- 5$) and I cannot connect it to my computer (Windows 8.1 64bit, Arduino IDE 1.6.8 installed).

The Arduino was bought as a clone but shows GRAVITECH.US on the front.
It has a FTDI FT232RL chip (1412-G B8908572) on the back.

When connecting the Arduino the power leds burns the TX and RX led flash a few times (really shortly) and then die. Then the yellow L leds blinks once per second continiously.(power to the Arduino comes from the USB cable, not from external power)

In the system tray I get a message saying

"The last USB device you connected to this computer malfunctioned,
and Windows does not recognize it."

In the device manager I get a node under Universal Serial Bus Controllers:

Unknown USB Device (Device Descriptor Request Failed).

When examining the properties of the device, the device-status is:

Windows has stopped this device because it has reported problems. (Code 43)
A request for the USB device descriptor failed.

I tried to reset the device
I tried different USB cables
I used another Windows 8.1 PC without Arduino IDE installed
I used an old XP computer

All give same error.

I read about the bricking of clones by the recent FTDI drivers...
I downloaded the FT_Prog tool V3.0.60 to check the PID, but the tool simply does not find the Arduino...

I'm out of ideas... does anyone have some left?

Thanks in advance!

Michiel


texts: Arduino PS2X module not working with controller

texts:
I have been trying to use the PS2X module to try to use my PS1 remote with my arduino (I am guessing that PS1 controllers will work because they are virtually the same ). The problem is that I don't want to download the module from the original website because it is not secure (it had HTTP instead of HTTPS) and the download file could contain viruses. Instead I got it off the arduino website. I have wired my controller correctly and have triple checked that all the wires are in the right positions and they seem to be. I then used the arduino example program given by the safely downloaded file. I complied it onto my arduino and I got the following message in the serial "No controller found, check wiring, see readme.txt to enable debug. visit www.billporter.info for troubleshooting tips
Unknown Controller type." I then looked into the text file to debug it and it told me to uncomment 2 of the lines which is what I did. I then ran the example program file again like how the readme file told me to, and I still get the same errors.

link github:https://github.com/madsci1016/Arduino-PS2X

link to the main: http://www.billporter.info/2011/03/27/arduino-playstation-2-controller-library-troubleshooting-guide/

wiring:

how I have wired it:


texts:
I am using atmega328p in my PCB prototype, due to some reason I can use only 4 volt for power supply.
My question is that
"How to run atmega328P through 4 voltage"


texts: Wireless Shield Not being detected w/ Arduino Uno R3

texts:
Wireless Shield is not being detected by arduino, not MAC address is displaying.
 Not sure what to try next, there is nothing noticeably wrong with the shield at first glance.

Green LED under status is on.

Shield Type: CC3000 WiFi Shield
Board Model: UNO R3

No Mac Address is being detected (my output in Serial Monitor)

Initializing Wifi...
MAC: 0:0:0:0:0:0
Scanning available networks...
** Scan Networks **
number of available networks:0

My Script:

#include <SPI.h>
#include <WiFi.h>

void setup() {
  // initialize serial and wait for the port to open:
  Serial.begin(9600);
  while(!Serial) ;

  // attempt to connect using WEP encryption:
  Serial.println("Initializing Wifi...");
  printMacAddress();

  // scan for existing networks:
  Serial.println("Scanning available networks...");
  listNetworks();
}

void loop() {
  delay(10000);
  // scan for existing networks:
  Serial.println("Scanning available networks...");
  listNetworks();
}

void printMacAddress() {
  // the MAC address of your Wifi shield
  byte mac[6];

  // print your MAC address:
  WiFi.macAddress(mac);
  Serial.print("MAC: ");
  Serial.print(mac[5],HEX);
  Serial.print(":");
  Serial.print(mac[4],HEX);
  Serial.print(":");
  Serial.print(mac[3],HEX);
  Serial.print(":");
  Serial.print(mac[2],HEX);
  Serial.print(":");
  Serial.print(mac[1],HEX);
  Serial.print(":");
  Serial.println(mac[0],HEX);
}

void listNetworks() {
  // scan for nearby networks:
  Serial.println("** Scan Networks **");
  byte numSsid = WiFi.scanNetworks();

  // print the list of networks seen:
  Serial.print("number of available networks:");
  Serial.println(numSsid);

  // print the network number and name for each network found:
  for (int thisNet = 0; thisNet<numSsid; thisNet++) {
    Serial.print(thisNet);
    Serial.print(") ");
    Serial.print(WiFi.SSID(thisNet));
    Serial.print("\tSignal: ");
    Serial.print(WiFi.RSSI(thisNet));
    Serial.print(" dBm");
    Serial.print("\tEncryption: ");
    Serial.println(WiFi.encryptionType(thisNet));
  }
}


texts: Smooth out digital signal from SW-420 vibration sensor in order to record duration?

texts:
I'm attempting to make a sensor that will record the duration and frequency of a pump going off. It always fires for at least 4 seconds, but the duration can be up to 7 days.  The vibration sensor I have is a SW-420, which I think will work. I'm fairly new at this, and I don't mind figuring out the actual code myself, but I'm running into newb problems.

Should I approach this as an interrupt that uses a callback while loop, or would it be better to look at it as a typical debounce sub? Is there a better solution?
Since the duration can (very rarely) exceed running for more than a few minutes, I'm wondering if I need an RTC module. The time is not very important, it just needs to be "close".
The duration info will be fed to node-red via MQTT. I can count frequency in that system... I'm trying to decide if I should do remote frequency calculations, or try and wrap it into the firmware on the Arduino. Any suggestions for this?

Bonus points if I can accomplish this without any additional libraries. I'd love to put this on an ESP8266.

Thanks for your help, I appreciate it.


texts: What is the best way to assign pins to an LED Cube?

texts:
I have made an LED cube that is a 3x3x3 design and was wondering if there is way to make a function in the Arduino IDE where each the layers of LEDs can be represented by a list with 1 being on and 0 being off:
{1, 0, 1, 0, 1, 0, 0, 1, 0} with the first number of the list being the first column, then the second column, etc. and the same for the rows which would be something like {0, 1, 0}. Does this make sense? If so, is there an idea for a function that could take these inputs and transform them into digitalWrite outputs? I am using an Arduino Nano for this, with pins 2, 3, 4, 5, 6, 7, 8, 9, and 11 used for the columns with A0, A1, and A2 being the rows of the cube.


texts:
I have been working on a hydroponic garden that is controlled with Arduinos. I have everything working except for the user interface. What I would like to do is have an LCD screen paired with a rotary encoder for use on the garden, and an ESP8266 WiFi module set as a server working with a custom Android app that I am writing.

I have been working on writing the app and the code that will allow the Arduino and the app to talk to each other, but I have been running into a problem. Sometimes the serial data between the ESP266 and the Arduino is not being picked up by the Arduino. I have verified that the data coming out of the WiFi module is correct, but the Arduino seems to be missing characters. This seems to happen almost at random. Sometimes it will work, and other times it will simply get stuck. I used a SoftwareSerial library to add an extra serial port and printed what the Arduino was receiving from the WiFi module, and it just seems to be missing random characters.

Up until now I have had the WiFi module connected and the LCD screen. I was using the LCD screen to display debugging messages. I took the LCD screen off and deleted all the LCD code and now everything seems to work just fine.

The LCD screen uses I2C.

Why does disconnecting the LCD screen solve the issue? Is there a way to make both run at the same time? The LCD uses I2C. I am unaware of anything that would prevent this from working.

Thanks.


texts:
I'm working on my first arduino project and i have my first problem dealing with servo motor , i'm trying to control the servo from my pc with this code but it just spining :

  #include <Servo.h>

Servo servo1;
long num;

void setup()
{
   servo1.attach(7);
   Serial.begin(9600);
   Serial.print("Enter Position = ");
}

void loop()
{
  while(Serial.available()>0)
  {
    num= Serial.parseInt();
    Serial.print(num);
    Serial.println(" degree");
    Serial.print("Enter Position = ");
  }
  servo1.write(num);
  delay(15);
}

this is my setup


texts: Controlling a LED array from Arduino NANO

texts:
I have a project Im currently busy with that I need a lot of help with.

What I want to do i create a flat 8x12 grid of LEDs and be able to control each individual LED independently from the others. I want to make "animations" for it (for now Im jut gona patch HIGH LOW through to the LEDs, but Im planning on making a full fledged program later on).

I saw guys on youtube creating LED cubes using the "column and row" technique, but Im not sure if that will work for me because I want to control each one independantly. Thats when my search led me to Shift Registers. Which will work best?

How would I manage the current for all the LEDs

Thank for taking the time to listen to a n00b like me :D


texts: Phasing a Stepper Motor Control Project Problem

texts:
I have a project involving stepper motors, in which I want to manage electronic equipment. What I'd like is a system allowing me to run the stepper motor continuously forward as long as I step on a floor pedal. I'd like to control the rotation speed with a variable pot if possible.

Next, I'd like the motor to automatically reverse once I release the foot pedal.  I'd like to control the reverse rotation speed with a variable pot if possible, and to control how long the motor runs in reverse before stopping.  That time may range from 1 ms to 10 sec. If possible, I would love to use pushwheel switches to control the reversing time.


texts:
Two days ago, my code is working fine on the arduino board. But yesterday, and today I tried so many time to upload the arduino code, which contains 1000 lines of code. It was successfully uploaded the code into arduino. But it only upload half code into arduino when I saw the serial monitor results (I use serial println(); test where the code is located. ) I am so confusing, why the code is working fine two days ago. but later, only half code being used. Please help.

Here is the memory I left when I uploaded it.

Sketch uses 48,314 bytes (19%) of program storage space. Maximum is 253,952 bytes.
Global variables use 2,603 bytes (31%) of dynamic memory, leaving 5,589 bytes for local variables. Maximum is 8,192 bytes.

Here is the code it stuck :
   Get Parameters
//
//  This function reads the information from the SD card for a given monitoring
//  site.
//

//

int getParameters(){
  String lowerLimit, upperLimit;

   char buffer[36];
  char newChar;
  int index, index1, index2, index3, line, theLength, numSensors;
  myFile.setTimeout(2000);
  line = 0;
  while (myFile.available()) {
    index = 0;
    do{
      newChar = myFile.read();
      buffer[index] = newChar;
      index += 1;
    }
    while(newChar != 10);
    buffer[index] = 0;
    theLines[line] = buffer;
    Serial.print(theLines[line]);
    //here the result is something like this
    //theLines[0] , class 111
    //theLines[1] , 192.168.1.10
    //theLines[2] , Mac Address

    line += 1;
  }

//so it is working fine above the code. But here is the problem stuck.
//the code cannot go through the rest of the code below. Nothing happened!!!
  for (int line = 0; line < 10; line++){
    Serial.print(theLines[line]);

  }


texts: How to create jumping wire using fritzing tool

texts:
I am tying to design my circuit diagram with the help of http://fritzing.org/home/ I designed like below circuit where wires are simply straight.

I want some kinda jumping wires with this tool. Does anyone know how to create these jumping wires ?


texts:
I've been trying to control a relay with a GSM shield for an Arduino project. I haven't had any success with either the Software Serial or the GSM library. I've declared the GSM variable in debug mode and it gives me the error AT%13%.
Using Software Serial, it hangs at SIM900.read().
The SIM card connects to the network, I can see that on the board - the LED flashes every 3 seconds and gives me signals for incoming calls and SMSs.

I can't tell if the error is with the SIM card, the connections to the Arduino board, the power supply (12V) or something completely different. Here are the two code examples I'm using with the different libraries.

Anyone else getting this error? What is the best way to make it go away?

Thanks in advance for any help!

SoftwareSerial.h

#include <SoftwareSerial.h>
char inchar; // Will hold the incoming character from the GSM shield
SoftwareSerial SIM900(7, 8);

int Relay1 = A2;
int Relay2 = A3;

void setup()
{
  Serial.begin(19200);
  //Set up relay control pins
  pinMode(Relay1, OUTPUT);
  digitalWrite(Relay1, HIGH);
  // wake up the GSM shield
  SIM900.begin(19200);
  delay(10000);  // give time to log on to network.
  SIM900.print("AT+CMGF=1\r");  // set SMS mode to text
  delay(100);
  SIM900.print("AT+CNMI=2,2,0,0,0\r");
  // output contents of new SMS upon receipt to the GSM shield's serial out
  delay(100);
  Serial.println("Ready...");
  }

void loop()
{

  //If a character comes in from the cellular module...
  if(SIM900.available() >0)
  {
    inchar=SIM900.read();
    Serial.println(inchar);
    if (inchar=='#')
    {...}
    SIM900.println("AT+CMGD=1,20"); // delete all SMS
  }
}

GSM.h - in this case I haven't even gotten past the .begin() command. This code is from the example at http://arduino.cc/en/Tutorial/GSMExamplesReceiveSMS

#include <GSM.h>

// PIN Number for the SIM
#define PINNUMBER ""

// initialize the library instances
GSM gsmAccess(true);
GSM_SMS sms;
GSM3_NetworkStatus_t   gsmStatus;
// Array to hold the number a SMS is retreived from
char senderNumber[20];

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }

  Serial.println("SMS Messages Receiver");
  char code = 'X';
  Serial.flush();
  gsmStatus = gsmAccess.begin(PINNUMBER,false,false);

  int retrycount = 60;
  while (gsmStatus != GSM_READY && retrycount-- > 0) {
    delay(1000);  // lower delay value could lead to unstable state
    theGSM3ShieldV1ModemCore.manageReceivedData();
    gsmStatus = gsmAccess.getStatus();
  }

  if (gsmStatus != GSM_READY) {
    Serial.println("\n[ERR]: GSM connection failed\n");
    Serial.flush();
    gsmAccess.shutdown();
    delay(250);
    digitalWrite(3,LOW);
  }

  Serial.println(" [DONE]");

  // connection state
  boolean notConnected = true;
  // Start GSM connection
  while (notConnected)
  {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY)
  {
      notConnected = false;
  }
    else
    {
      Serial.println("\nNot connected");
      delay(1000);
    }
  }
  Serial.println("GSM initialized");
  Serial.println("Waiting for messages");
}


texts: I am trying to control a continuous servo (mg996r) with an RF remote but it's not working, I'm not sure what's wrong

texts:
I am trying to control a continuous servo (mg996r) with an RF remote, but it's not working; the servo just spins in one direction, I don't know what's wrong.
I am new to Arduino so I don't really know if the code is correct.
This is my code:
#include <Servo.h>

Servo servothumb;
Servo servoindex;
Servo servomiddle;
Servo servoring;
Servo servopinky;

void setup() {
  pinMode(2,INPUT);
  pinMode(3,INPUT);
  pinMode(4,INPUT);
  pinMode(5,INPUT);
  Serial.begin(9600); // setting baud rate
  Serial.println(" Data 4 Ch Remote Control");
  servothumb.attach(9);
  servoindex.attach(10);
  servopinky.attach(11);
  servoring.attach(12);
  servomiddle.attach(13);
}

void loop() {
  if (digitalRead(2) == HIGH) { // Button B pressed
    Serial.println("B");
    servothumb.write(90);
    servoindex.write(90);
    servopinky.write(90);
    servoring.write(90);
    servomiddle.write(90);
  } else {
    servothumb.write(90);
    servoindex.write(90);
    servopinky.write(90);
    servoring.write(90);
    servomiddle.write(90);
  }

  if (digitalRead(3) == HIGH) { // Button D pressed
    Serial.println("D");
  }
  if (digitalRead(4) == HIGH) { // Button A pressed
    Serial.println("A");
    servothumb.write(0);
    servoindex.write(0);
    servopinky.write(0);
    servoring.write(0);
    servomiddle.write(0);
  } else {
    servothumb.write(90);
    servoindex.write(90);
    servopinky.write(90);
    servoring.write(90);
    servomiddle.write(90);
  }
  if (digitalRead(5)== HIGH) { // Button C pressed
    Serial.println("C");
    servothumb.write(180);
    servoindex.write(180);
    servopinky.write(180);
    servoring.write(180);
    servomiddle.write(180);
  } else {
    servothumb.write(90);
    servoindex.write(90);
    servopinky.write(90);
    servoring.write(90);
    servomiddle.write(90);
  }
}


texts: Having a problem to control digital servo with HC-06 bluetooth module

texts:
There are two problems to control digital servo(HD-1810MG) and HC-06 bluetooth module connection.

When I put a specific number to servo(in the video, I put 45), it shakes too much and shows useless movements before get to the right angle. I have no clue why this happens. Should I add more code to control it correctly?

This is my code.

#include SoftwareSerial.h
#include Servo.h

Servo myServo;
int TxD = 10;
int RxD = 11;
SoftwareSerial bluetooth(TxD, RxD);

void setup() {
  myServo.attach(9);
  Serial.begin(9600);       // start serial communication at 9600bps
  bluetooth.begin(9600);
}

void loop() {
  if (bluetooth.available()>0)
  {
    int servopos = bluetooth.read();
    Serial.println(servopos);
    myServo.write(servopos);
    delay(100);
  }
}

I used Nexus 5X and apk app to pair with HC-06. It pairs well at the first time of connection, but it loose connection after servo moved once. Application said it is connected with bluetooth, but HC-06's LED is blinking(which means disconnected). How can I maintain connection with HC-06?

This is my board.

And I made apk app using MIT App Inventor 2.

I'm so new to arduino and I'm not in major of engineering. Please give me an advice!


texts: I salvaged an SPI interface LCD from an old CDMA telephone. It seems it uses SPI to display something on the screen. The pins marks are DATA, CS, SCLK, BL, VDD, GND, LED, A0, and RES. How do I wire it up to an Arduino?


texts: Will L293D arduino shield lose functionality if I connect it with jumpers instead of mounting on arduino?

texts: I'm new to arduino and have bought a L293D motor driver shield which have no heads on the pins. I looked at the pinout and it seems that shield does not use any of the pins "by default". So will it work properly if I connect it like it isn't a shield(without mounting), because I need to use other pins and it would be nice if I don't need to solder them. I know it's some basic stuff but I want to avoid messing up at the very beginning if I don't have to. Thanks.


texts: Using external reset to trigger radio receipt

texts:
I am designing a low-power RF application using an ATTiny (Adafruit Trinket).

When the system receives a radio signal, it needs to read some sensors, and transmit with that data. Because I am short on pins, I am trying to think of creative (low-pin count) ways to design this system.

My current idea is:

Put the AVR to sleep.
Connect the radio's Rx Interrupt pin to the AVR Reset pin
When the AVR is reset, check the radio buffer

(if there's nothing in the buffer, assume this is a real power-on reset and go back to sleep)

Otherwise, read sensors, transmit
Go back to sleep

My aim here is that the AVR will use very little power while sleeping (furthermore, it will only need to wake up a few times per day).

Is it reasonable to use the AVR reset pin in this manner? Any gotchas to be aware of?


texts:
I need to utilize almost 100 Arduino devices in a plant and my clients want a data dashboard. I'm wondering how to utilize MQTT for optimizing the data among these devices and the data dashboard.

My questions are:

Can I implement MQTT in server using only .NET environment without Java and so forth?
Can I have the Broker in a private mode, I mean, neither using nor echoing information to internet?

Thanks for any help!


texts:
I saw two peculiar things while googling this subjects.

Sometimes Tx and Rx are connected directly despite the fact, that it works on different voltages, sometimes resistor dividor is used, sometimes it goes through resistor. Why no consensus? What are differences?
Why contributors are so stubborn to use software UART? Is there any reason I can't understand, that should stop me from using built in UART?


texts:
I have an ACS712 (5v sensor), an ADS1115 (5 or 3.3v) and an ESP8266 board (3.3v).

I know I can't directly use the ACS with the ESP without a voltage divider on the analog pin. So I figured I could run the ADS and the ACS off 5 volts as the ADS communicates over I2C. Does this cause any issues with the SDA/SCL lines on the ESP?

What is the correct way in going about this?


texts: Monitor serial0 while code is being uploaded


texts: How can a USB keyboard emulator (TrinketKeyboard) type Unicode characters?

texts:
I've got an Adafruit Trinket microcontroller set up using this USB keyboard tutorial, and it works great.

I'd like to set up my project to type a shruggie ( ¯\_(ツ)_/¯ ) when I press a hardware button.

My naive solution was:

TrinketKeyboard.print("¯\_(ツ)_/¯");

But that only printed the underscores, parentheses and slashes, not the "hands" or the "face."

Is there a standard keyboard input method I could use so this device, when plugged into any Mac, will type out a string that includes Unicode (specifically Katakana) characters?

An ideal solution does not require configuring the machine before plugging this widget in, and doesn't require changing state on the machine -- although I'll take what I can get! :) (e.g., configuring Japanese keyboard support and toggling input source -- all of which is done blind since the computer can't give feedback to a lowly keyboard -- is un-ideal.)


texts: Project structure to build for PC and Arduino

texts:
Recently I have started developing for Arduino Uno. I have 10 years experience in software development (C#, Delphi), but not much with C/C++.
Compiling the Arduino sketches seems a little slow, and debugging isn't as convenient as it could be on a PC (compile, upload, watch the serial monitor, modify code, start over.... way too slow with lots of unnecessary steps)
So what I would like to achieve is to organize my code in a way to be able to compile my code either to Arduino, or to PC for debugging purposes (to a small console app). I know that there are libraries that cannot be used on a PC, but those can be abstracted away (hidden behind a facade or something like that). Unfortunately I could not find any tutorials, or articles how to do this. So I hope you can help me out.

BTW I'm using Visual Studio (with Visual Micro) on a Windows 10 computer.


texts:
I am reaching out for help on a project I am working on. We are trying to integrate a reaction torque sensor and I am having a hard time deciding how to go about it. Previously I assumed that like my load cell I would be able to use the HX711 module to connect my Torque sensor to my Arduino. The Torque sensors uses a Wheatstone bridge configuration, which is great for this module. The problem I ran into is that the TRT-25 Torque sensor requires an excitation voltage of 10V and my Arduino is only supplying 5V. When I tried powering my sensor separately with 10V I quickly found out that these HX711 modules are not designed to handle 10V...
Needless to say that I am now wondering how I should be power my sensor, but also which A/D converter can be used to get this working. The same manufacturer sells all the components to get this working, but it is hundreds of dollars more and our budget doesnt allow for it. I am posting links here so you can see the sensor. What I am considering now is finding a 10V source and connecting the signal pins to my analog pins on my Arduino. I am hoping based on the raw value I can compute a torque measurement based upon this small piece of information their tech support gave me.  (X mv/v * EXCITATION v = TORQUE in/lbs).
FYI, I dont have much more information outside of what it is on the site for the sensor. My project uses a small enclosure and I have a arduino proto shield to power my other 3 sensors. I am limited on space but could probably incorporate a small supply and replace the current HX711 module.
HX711
https://www.transducertechniques.com/trt-torque-sensor.aspx


texts: Problem with tachometer using attachInterrupt and servo

texts:
So I am creating a tachometer using black/white detector sensor. Here's the code.

unsigned long WaktuOLD;
unsigned long WaktuNOW;
int Detection = HIGH;
int Counter = HIGH;
float HitungWaktu;
float HitungRPM;

void setup() {
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(3), rpm, RISING);
  WaktuNOW = millis();
}

void rpm() {
  Detection = digitalRead(3);
  if (Detection == HIGH && Counter == LOW) {
    WaktuNOW = millis();
    HitungWaktu = WaktuNOW - WaktuOLD;
    HitungRPM = 60 / (HitungWaktu / 1000);
    Counter = HIGH;
  } else if (Detection == HIGH && Counter == HIGH) {
    Counter = LOW;
    WaktuOLD = millis();
  }
}

void loop() {
  Serial.println(HitungRPM);
  delay(5000);
}

The code works well and it can read RPM correctly. And then from the same arduino, I am controlling a servo motor, in this case I am using GWS03N/STD/F, with this code :

#include <Servo.h>

Servo myservo;
int pos = 0;

void setup() {
  myservo.attach(9);
}

void loop() {
  myservo.write(90);
}

And this code works well too.

But, when I am trying to combine both codes, only the servo code is working well. The tachometer reading is not correct (the reading must be around 1000-1500rpm, but now it reads 3000-30krpm). I am already trying to change my tachometer interrupt to pin 2 or 3, and servo to 3, 5, 6, and 9 but still the same.

So what is wrong in here. Thank you so much.

This is my code when combining both codes.

#include <Servo.h>

Servo myservo;
int pos = 0;
unsigned long WaktuOLD;
unsigned long WaktuNOW;
int Detection = HIGH;
int Counter = HIGH;
float HitungWaktu;
float HitungRPM;

void setup() {
  Serial.begin(9600);
  attachInterrupt(digitalPinToInterrupt(3), rpm, RISING);
  WaktuNOW = millis();
  myservo.attach(9);
}

void rpm() {
  Detection = digitalRead(3);
  if (Detection == HIGH && Counter == LOW) {
    WaktuNOW = millis();
    HitungWaktu = WaktuNOW - WaktuOLD;
    HitungRPM = 60 / (HitungWaktu / 1000);
    Counter = HIGH;
  } else if (Detection == HIGH && Counter == HIGH) {
    Counter = LOW;
    WaktuOLD = millis();
  }
}

void loop() {
  Serial.println(HitungRPM);
  myservo.write(90);
  delay(5000);
}


texts: How to use virtual connection between matlab simulik and arduino in isis proteus?

texts: I don't know how to connect between matlab simulik and arduino card in isis proteus by using a virtual ports


texts: Arduino Uno Keeps Resetting (Power issue)

texts:
Arduinites!

Hoping you can help a newbie. I'm putting together a board for a Christmas present this year. It's replacing the factory board that comes on a beer fridge/vending machine, with minimal interactions.

Basically, when the beer can falls into an outlet chute, it trips a switch that triggers some LEDs and audio. Pretty simple stuff. The fridge supplied +5v to the previous board, so I thought I could remove it and simply swap in the Arduino.

The code runs fine when the Arduino is powered by USB/laptop. I spliced a USB header onto the +5v wire supplied by the fridge and plugged it all in. Now, it will boot up, play some weird fuzz out of the speaker, and reset after about 10 seconds.

How can I use the +5v to power my nutty creation? The previous board had a capacitor on it which I removed (I know next to nothing about some of this stuff but it seems like maybe that would help?)

Here's a photo of what I'm working with. If I need to provide any additional information or photos I can do that.

If you have any advice, please ELI5 with regards to what I might be able to place in my circuit to get this working (links or definitions are incredibly helpful!)

Any help is appreciated!


texts:
I am trying to use FreeRTOS's vTaskDelay() function in order to periodically execute tasks.  The latest version of FreeRTOS came with the "tick" time set to 15 ms. Therefore, the smallest resolution I can delay for is 15 ms. I would like to lower this resolution to at least 1 ms.  Is it possible to configure FreeRTOS in this way?  I found this answer online : http://www.freertos.org/FreeRTOS_Support_Forum_Archive/November_2012/freertos_Problem_changing_Tick_time_from_1ms_to_10ms_6231539.html.

But for me, the configTICK_RATE_HZ is not defined and it seems to be using a watchdog timer to enforce the 15 ms resolution. I think the forums are referring to an earlier version.


texts: Two SSL connections at the same time on Uno WiFi rev 2

texts:
So I want to have one persistent SSL connection to a cloud server (Azure IoT Hub) to upload telemetry and another SSL connection to a server to perform a simple GET request every 30 minutes.
I've setup my first connection and telemetry is successfully sent, then I connect to the second server, I get a response, close the connection, but my first connection to Azure IoT Hub crashes.
I haven't found any information online on how many simultaneous SSL connections the Arduino Uno WiFi Rev. 2 supports nor any guidance on how to use more than 1 SSL connections. Any help would be greatly appreciated.


texts:
I'm trying to build a low power GPS datalogger and I am trying to get the Mediatek based GPS module (Quectel L80-R) to run in periodic mode. I've sent the PMTK225 code to the module with various parameters, but it never seems to go into stand by or back up mode. Code below.

//Testing that commands sent to the GPS unit work

#include <NeoSWSerial.h>
NeoSWSerial gpsPort(3,2); // pins 3/2

#include <NMEAGPS.h>
NMEAGPS gps;

void setup() {

  // connect at 115200 so we can read the GPS fast enough and echo without   dropping chars
  // also spit it out
  Serial.begin(115200);

  gpsPort.begin( 9600 );
  gps.send_P( &gpsPort, F("PMTK605")); //firmware version
  delay(100);
  //gps.send_P( &gpsPort, F("PMTK314,-1")); //reset to default
  //gps.send_P( &gpsPort, F("PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC_GGA
  //gps.send_P( &gpsPort, F("PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC only
  delay( 100 );
  //gps.send_P( &gpsPort, F("PMTK220,200") );  // 5Hz
  //gps.send_P( &gpsPort, F("PMTK220,1000") ); //1hz
  delay( 100 );
  //gps.send_P( &gpsPort, F("PMTK225,0")); // normal mode
  //gps.send_P( &gpsPort, F("PMTK223,1,25,180000,60000")); // ephemeris data receiving
  gps.send_P( &gpsPort, F("PMTK225,2,3000,10000")); //period mode but not working
  //gps.send_P( &gpsPort, F("PMTK161")); //stand by mode
  //gps.send_P( &gpsPort, F("PMTK103")); //cold start
  delay(100);
  gps.send_P( &gpsPort, F("PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0") ); // RMC only

  //gps.send_P( &gpsPort, F("PGCMD,33,0") );   // No antenna status messages needed
  delay( 100 );

  Serial.println("Ready!");
}

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


texts:
On an ESP32 board I am trying this simple code to control the onboard led.
But if I set it to HIGH, led is OFF, if I set it to LOW, led is ON (fully bright).
What could cause this ?
The board has one red and one blue leds, the blue one is the one that can be controlled.
#define onboard_led 2

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

void loop() {
    digitalWrite(onboard_led, HIGH);
    // digitalWrite(onboard_led, LOW);
}

Edit: it was a board like this ("Geekcreit" I think):


texts: Uno - measure the voltage, NOT connecting GND

texts:
I'm trying to use an Arduino Uno, to measure the Voltage over a Resistor in a circuit. I guess the usual way would be to connect GND to one side of the Resistor and the AD0 Pin to the other end, and scale the (0..1023) to (0..5V).

The problem is however, that connecting the GND to one side of the Resistor affects the circuit. Since the GND of Arduino is also connected to a Servo Driver (and other stuff), Some of the power that was supposed to be consumed by my Resistor, is now consumed by the parallel circuits.

Is there any way to measure the Voltage over the resistor without using GND?


texts: How to display a number using SevSeg library on 4 digit 7 segment LED display

texts:
I am getting error with this. It is displaying those segments which are not to be displayed, i.e., 3.141 is dark and other segments are red.

#include "SevSeg.h"

SevSeg sevseg; //Initiate a seven segment controller object

void setup() {
    byte numDigits = 4;
    byte digitPins[] = {2, 3, 4, 5};
    byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};
    sevseg.begin(COMMON_ANODE, numDigits, digitPins, segmentPins);
    sevseg.setBrightness(1000);
}

void loop() {
    sevseg.setNumber(3141, 3);
    sevseg.refreshDisplay(); // Must run repeatedly
}


texts: Serial.print start prints unreadable character without any reason

texts:
I wrote the following code. The idea is to execute some AT command on my ESP-01 module. The problem is that first command is execute without problem, the second sometimes but the reply on AT+GMR is the following:
    AT

OK
AT+GMR

AT version:1.1/0.0(May 11 3016 18:09:57)
SDK version:1.5.ar.0
AR)�WS�TZ�j
C�j�L�AZCA�O�C�

FINE

The problem is that, after some thing that I don't understand, the formatting (maybe the baud change?) gone wrong. Then the reply of the following commands became unreadable. Any idea why it happens?

#include <SoftwareSerial.h>
#define DEBUG true
SoftwareSerial wifi(2,3);

void setup() {
   Serial.begin(115200);
   wifi.begin(115200);
   sendCommand("AT\r\n", 2000);
   sendCommand("AT+GMR\r\n",2000);
   sendCommand("AT+CWMODE=2\r\n", 2000);
   sendCommand("AT\r\n", 2000);
   Serial.print("\n\nFINE");
}

void loop() {}

String sendCommand(String cmd, int timeout){
   wifi.print(cmd);
   return readSerial(timeout);
 }

 String readSerial(int timeout){
   long int time = millis();
   String res = "";
   while( (time+timeout) > millis() ){
        while(wifi.available()){
          char c = wifi.read();
           res += c;
        }
    }
    if(DEBUG)
       Serial.print(res);

    return res;
 }


texts: I am working on a project where I need to use around 50 LED's connected to an Arduino UNO board. To begin with i worked on the tutorial provided by Arduino (https://www.arduino.cc/en/Tutorial/ShiftOut) to connect two shift registers(74HC595). Everything works fine, but the shift registers get very hot in just a few minutes. Is this normal?


texts: MegaCore ATmega2560 PB7 activation randomly at boot

texts:
I uploaded in my custom board (ATmega2560 with an external oscillator 16MHz) the MegaCore bootloader using the AVR pinout. I found that when I switch on the board the pin PB7 is activated 2 short times. This happens even with a blank Arduino sketch.
I found out that the problem was the reset pin connection. When the reset pin (for uploading a new sketch) is connected to the board I got the previous behaviour.
How can the reset pin affect only the pin PB7?
PS I found this issue even in the Arduino Mega standard bootloader.


texts: Integrating 2 push buttons to toggle the LED ON and OFF

texts:
Hey guys need your help in verifying out this program about toggling the LED ON and OFF using 2 push buttons.What i actually want is to let my LED stay ON when i press and even leave the push button-1 , and on pressing and leaving the push button-2 i want the led to turn off and no matter how many times i press the push button-1 i want it to turn ON the LED and the push button-2 should only turn off the LED.but with my program i am only able to see the LED to be at HIGH state,It is not shifting to LOW state on clicking push button-2.

This is my sketch :-

    /* LED CONTROLLED WITH 2 PUSH BUTTON PROJECT
       BY ARSH BANSAL

 CIRCUIT :-
 i) LEDPIN CONNECTED PIN 13.
 ii) PUSHBUTTON1 CONNECTED TO PIN 8.
 iii) PUSHBUTTON2 CONNECTED TO PIN 7.
 iv) BOTH THE PUSH BUTTONS CONNECTED PARALLELY, EACH WITH A 1K PULLUP RESISTOR AND BOTH THE PUSH BUTTONS CONNECTED TO 5V SUPPLY.
   */

 int ledpin = 13;
 int pushbutton1 = 8;
 int pushbutton2 = 7;
 boolean lastbuttonstate1 = LOW;
 boolean lastbuttonstate2 = LOW;

 void setup()
 {
   pinMode(ledpin,OUTPUT);
   pinMode(pushbutton1,INPUT);
   pinMode(pushbutton2,INPUT);
 }

 void loop()
 {
   if ( digitalRead(pushbutton1)== HIGH && digitalRead(pushbutton2) == LOW && lastbuttonstate1 == LOW )
    { digitalWrite (ledpin,HIGH) ;}

   else ( digitalRead(pushbutton1) == LOW && digitalRead(pushbutton2)== LOW && lastbuttonstate1 == HIGH)
    ; { digitalWrite (ledpin,HIGH) ; }

    if ( digitalRead(pushbutton1)== LOW && digitalRead(pushbutton2) == HIGH  && lastbuttonstate2 == LOW)
    { digitalWrite (ledpin,LOW) ;}

   else ( digitalRead(pushbutton1) == LOW && digitalRead(pushbutton2)== LOW  && lastbuttonstate2 == HIGH)
    ; { digitalWrite (ledpin,LOW) ; }
    }


texts: What are the advantages of "Arduino compatible" boards

texts:
There are countless boards called "Arduino compatible board". Some of them have specialized hardware features such as WiFi, SD card readers etc., but most of them seem like plain Arduino copies to me.

Sure, they are a bit cheaper, but for me the price difference doesn't make me favor the money I'd safe over the potential issues I have yet to discover.

Question: What are the benefits (or disadvantages) of Arduino compatible boards (the ones without the "extras") in general? Do you know an Arduino compatible board that you would recommend for some extraordinary features?


texts: I'm using a basic relay and I want to use 12 like this. Each one needs 50 milliamps, but the Arduino can supply only 300 milliamps. What can I do?


texts: Have terminal bash script act as virtual "button" for Leonardo?

texts:
I've searched quite a lot for this and tried to piece bits of code together but with no luck so far.

All i'm looking to do is have a command I can run in terminal/bash script on the Mac trigger some code to run on the Arduino (Leonardo)

It doesn't matter what data the Mac sends, I only have one command to run so it doesn't need to look like separate buttons or anything.

So far i've tried

int incomingByte = 0;   // for incoming serial data
void setup() {
Serial.begin(9600);
}

void loop() {

    // send data only when you receive data:
    if (Serial.available() > 0) {
            // read the incoming byte:
            incomingByte = Serial.read();
//run commands
  }
    }

and then from terminal/script both

echo "1" > /dev/tty.usbmodemHIDPC1 9600

and

screen > /dev/tty.usbmodemHIDPC1 9600

I see the Arduino light flash when I run those two commands in terminal which would seem to suggest that its receiving the data, but nothing runs.

I have stripped out my code that is due to be run by the way for simplicity. I've got working keyboard presses ready to go to enter in the "run commands".


texts:
I just installed the Arduino IDE in openSUSE 13.1. I am able to open the application using the run dialogue, so I know it has installed. However, there is no way to open the IDE from any application launcher. I have tried both the Kickoff and Lancelot applciation managers. I have also tried to uninstall and re-install the IDE, both through the 1-click on the Arduino website as well as through the command line.

Does anyone know why I am unable to launch the application from the launcher? Thanks in advanced for any help!


texts: if/else on digitalRead not executing on 'else' portion

texts:
I am a beginner with C++ but used to be good with BASIC (2 decades ago lol). I'm building a peristaltic metered doser that allows you to input desired mL on a 4x4 keypad and then when 'fill' button is pressed it doses the desired mLs through the peristaltic.

I'm still drafting/printing the peristaltic housing and all of that but in the meantime I want to get as much of the coding done as possible. It's still incomplete, but one of the functions I want the doser to have is a 'PRIME/FLUSH' button.

Originally I wanted the button to run the pump as long as the button is held down to prime the tubing with solution or flush the tubing with DI water. But I haven't had luck figuring out how to use a 4x4 button in momentary switch mode.

A workaround I had was to have the button be an on/off button. So press it once, pump turns on, press it again, pump turns off. Since the pump isn't printed yet I've been using the onboard LED as a tester for the coding (hence the LED_BUILTIN).

The issue, from my research I figured what I would need was an if/else statement. When the button is pressed (in this case the 'a' button), it reads the LED_BUILTIN status and if its HIGH it turns it off and if its LOW it turns it on.

But the 'if' part is working, it turns it on, but the 'else' part is not. When the LED is already on and the 'a' button is pressed, it stays on and doesn't rewrite to LOW.

Code below, any advice?

#include <KeypadShield.h>

KeypadShield keypad;

#include <LiquidCrystal_I2C.h>
#include <Wire.h>

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

char Data[15];
byte data_count = 0;

int x;

char customKey;

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

  keypad.begin();
  lcd.begin(20,4);
    lcd.setCursor(4,0);
    lcd.print("Let's Fill!");
    lcd.setCursor(4,1);
    lcd.print("Designed by");
    lcd.setCursor(4,2);
    lcd.print("JP");
    lcd.setCursor(5,3);
    lcd.print("2019 v1.0");

    delay (2000);

    lcd.clear();

    lcd.setCursor(1,0);
    lcd.print("Enter volume in mL");
    lcd.setCursor(3,1);
    lcd.print("on keypad then");
    lcd.setCursor(5,2);
    lcd.print("press DONE");
    lcd.setCursor(0,3);
    lcd.print("mL:");
}

void softReset()
{
asm volatile ("  jmp 0");
}

void loop()
{
    customKey = keypad.getNextKeypress();

    if (customKey)
    {
      if (customKey == 'a')
      {
        if (digitalRead(LED_BUILTIN == LOW))
        {
          digitalWrite(LED_BUILTIN, HIGH);
          lcd.clear();
          lcd.setCursor(5,1);
          lcd.print("FLUSHING");
        }
        else
        {
          digitalWrite(LED_BUILTIN, LOW);
          lcd.clear();
          lcd.setCursor(1,0);
          lcd.print("Enter volume in mL");
          lcd.setCursor(3,1);
          lcd.print("on keypad then");
          lcd.setCursor(5,2);
          lcd.print("press DONE");
          lcd.setCursor(0,3);
          lcd.print("mL:");
        }
      }

      if (customKey == 'd')
      {
       softReset();
      }

      if (customKey != 'p' && customKey != 'a' && customKey != 'b' && customKey != 'c' && customKey != 'd' && customKey != 's')
      {
        Data[data_count] = customKey; // store char into data array
        lcd.setCursor(data_count+3,4); // move cursor to show each new char
        lcd.print(Data[data_count]); // print char at said cursor
        data_count++; // increment data array by 1 to store new char, also keep track of the number of chars entered
        x = atoi (Data); //convert string to integer 'x' for use in equations
      }

     if (customKey == 'p')
      {
       lcd.clear();
       lcd.setCursor(7,0);
        lcd.print(x);
        lcd.setCursor(Data[data_count]+13,0);
        lcd.print("mL");
        lcd.setCursor(0,1);
        lcd.print("FILL --> fill");
        lcd.setCursor(0,2);
        lcd.print("RESET --> change mL");
        lcd.setCursor(0,3);
        lcd.print("FLUSH --> finish");

      }
    }
};


texts: Does any board provide more than 1024 analog input values?

texts:
The Arduino boards provide an analog input range of 0V to 5V which translates to 0 to 1023 integer values. The range is determined by the on-board ADC, which in the case of the Uno is a 10 bit ADC (2^10 = 1024).

Do any of the official boards have a larger (>10 bits) ADC? Do any boards provide a wider range of analog input values?


texts:
I've just bought a new LinkIt ONE IoT prototyping board, and I'm having trouble getting started with it.

I'm working on a mac. I've installed the LinkIt ONE SDK onto my Arduino IDE as specified in the instructions here: http://labs.mediatek.com/fileMedia/download/5fed7907-b2ba-4000-bcb2-016a332a49fd

When I go to upload my first sketch to my board, the sketch compiles and goes through uploading, but before it uploads, it stops uploading and the Arduino IDE perpetually tells me "Uploading...". When I look at the console below, it's telling me this:

[txd] AT

[txd] AT

[medrv]: Time out call back

[error] time out
[medrv]: Kill timer, event is AT_TIMEOUT

I've read some forums about an issue similar to this on the MediaTek website, but they don't help with the issue on the Mac. The ability to use LinkIt ONE on a Mac is new only this month, so I believe if we come up with a fix for this issue, it will help lots of people in the future who have this similar problem.


texts:
So I made this circuit + a momentary push button on D2 and GND:

Because I don't use a real arduino, I use the RAW port to act like the +5V port. It all worked with a single LED without the npn transistor. Now, with the transistor, the strip of LED's doesn't turn off anymore when I hit the button. The code:

 #include <SoftwareSerial.h>

  #include <Keyboard.h>

  boolean toggle = false;
  int inPin = 2;
  int outPin = 3;

  int state = HIGH;
  int ledOn;
  int reading;
  int previous = LOW;

  long time = 0;
  long debounce = 200;

  void setup() {
    // make pin 2 an input and turn on the
    // pullup resistor so it goes high unless
    // connected to ground:
    pinMode(inPin, INPUT_PULLUP);
    pinMode(outPin, OUTPUT);
    Keyboard.begin();
  }

  void loop()
  {
    reading = digitalRead(inPin);
    ledOn = digitalRead(outPin);

    // if the input just went from LOW and HIGH and we've waited long enough
    // to ignore any noise on the circuit, toggle the output pin and remember
    // the time
    if ((reading == LOW) and (ledOn == LOW)) {
      state = HIGH;
      Keyboard.press((char) 128);
      Keyboard.press('r');
      delay(50);
      Keyboard.releaseAll();
      delay(200);
    }

    if ((reading == LOW) and (ledOn == HIGH)) {
      state = LOW;
      Keyboard.press((char) 32);
      delay(10);
      Keyboard.releaseAll();
      delay(100);
      Keyboard.press((char) 177);
      delay(10);
      Keyboard.releaseAll();
      delay(200);

      time = millis();
    }

    digitalWrite(outPin, state);

    previous = reading;
  }


texts:
I want to track my pets using some sensors (their location in space) but I could only find radio sensors. These radio sensors are big and cumbersome for my dogs to carry around.

Is there some sensor that I can use in order to locate them in space? I want to use my arduino board to capture the data.


texts: Specific noise while using arduino ADC in free running mode

texts:
To make an oscilloscope in matlab environment, for data acquisition on arduino side, when inbuilt analogRead() is used, it's working fine, but with very low sampling rate, that aliasing is clearly observed. That too, non-uniform sampling. Thus listing out the drawbacks:

Very slow data rate, even if, sent with 115200 baudrate,
Aliasing
Non-uniform sampling

Thus, to overcome above, ADC in free running mode was used, with 16 as prescaling factor, thus 76.9KHz sampling rate (counting each ADC as 13 clock cycles). Thus, data is uniformly sampled now. Also it is quite fast, because of sampling, and is observed. The only problem now exists is, output has a specific noise. The data being sampled is 50Hz sinusoidal current waveform by current sensor ACS712. It overlays instantaneous current waveform over a bias of 2.5V. Thus, when signal is not present, a constant voltage of 2.5V is observed, thus, 512, because of mapping to 255 range.. 127. But in the case of free running mode, along with 127, 191, 63 only are observed. And it can also be seen that nearly 127 = 63*2, and 191 = 63*3. And when current waveform exists, it's highly distorted, but perceptible that it's not the previous signal of just 127, 191, 63. In the below plot, current is passed since 33.5sec.

I am unable to understand this, structured noise. What may be the reason ? I have once read, last two MSB bits get noisy at this sampling rate, but then how would 127, jump to 191. Why is 63 getting added, subtracted at each instant ?
I understand the reason for non-uniform sampling now is because of Serial.print(), whose interrupts are obstructing the ADC interrupts, but don't understand the reason behind the noise observed.

Following is the code uploaded in arduino. Serial data is read from matlab by fread() function.

long t1=0,ts1=0,ts2=0;
int aval=0, val=0;

void setup() {

 TIMSK0 = 0x00;           // disable timer (causes anoying interrupts)
 DIDR0 = 0x3F;            // digital inputs disabled
 ADMUX = 0x40;            // measuring on ADC0, right adjust, AREF reference
 ADCSRA = 0xAC;           // AD-converter on, interrupt enabled, prescaler = 16
 ADCSRB = 0x00;           // AD channels MUX on, free running mode
 bitWrite(ADCSRA, 6, 1);  // Start the conversion by setting bit 6 (=ADSC) in ADCSRA
 sei();
 Serial.begin(115200);
 t1=millis();
 }

ISR(ADC_vect)
{
 aval = ADCL;
 aval += ADCH << 8;
}

void loop() {
val = map(aval, 0, 1023, 0, 255);
Serial.write(val);
delay(10);
}


texts:
I will explain my task in a simplified way. I'm communicating among 3 Xbee's.

The attached code is for the sender Xbee. This Xbee actually sends multiple values of value1 (here for simplification I assigned it to constant value 10). For finding the value1 it does some other calculations as well and then assigns it.

But I find that if I reduce or remove the delay(100) I end up receiving improper values. I guess delay gives a buffer time for data transmission but my question is how to do I calculate the minimum delay or how can justify that this is the delay needed ?

I hope you can understand my question. If not please comment I will give some more pertinent details.

  // Sender Xbee
    void setup()
    {
    Serial.begin(9600);
    }
    void loop()
    {
    int value1 = 10; // some hardcoded values to send
    Serial.print('H'); // unique header to identify start of message
    Serial.print(value1,DEC);
    Serial.print(","); // note that a comma is sent after the last field
    Serial.print('\n'); // send a cr/lf
    delay(100);
    }


texts:
I am trying to get a strain gauge working with the HX711 load cell amp. I posted about this a few months ago and got told to get some high precision resistors for the wheatstone bridge. I have now obtained these (https://www.digikey.fi/product-detail/en/vishay-foil-resistors-division-of-vishay-precision-group/Y0007350R000T9L/Y0007-350-ND/2609877).
My wiring and code are as shown below. The wiring is basically a wheatstone bridge with one arm replaced by the strain gauge and each of the corners of the wheatstone bridge connected to RED, BLK, WHT and GRN on the red HX711 (BLK and GRN are the ones connected to the strain gauge arm). On the other side, VCC is to 5V on the arduino, GND to GND on the arduino, DAT to digital pin 5 and CLK to digital pin 6.
#include "HX711.h"

#define calibration_factor -550.0 //This value is obtained using the SparkFun_HX711_Calibration sketch
#define DOUT  5
#define CLK  6

HX711 scale;

void setup() {
  Serial.begin(9600);
  Serial.println("HX711 scale demo");

  scale.begin(DOUT, CLK);
  scale.set_scale(calibration_factor); //This value is obtained by using the SparkFun_HX711_Calibration sketch
  scale.tare(); //Assuming there is no weight on the scale at start up, reset the scale to 0

  Serial.println("Readings:");
}

void loop() {
  Serial.print("Reading: ");
  Serial.print(scale.get_units(), 1); //scale.get_units() returns a float
  Serial.print(" lbs"); //You can change this to kg but you'll need to refactor the calibration_factor
  Serial.println();
}

The problem is that the values are not changing when I bend the strain gauge. Only random, short spikes in values are happening and they do not seem to correspond to the strain gauge being strained or unstrained (see below). Any ideas what could be causing this?

Any help is greatly appreciated.


texts: Trying to play audio files on arduino via Usb Host Shield

texts:
I want to build a program that will seek audio file inside a USB DOK (DisK On Key/Pen Drive) when it is inserted to the Circuits@Home USB Host shield. After a specified file will be found i want it to be played via the Audio library and the Teensy 3.1 12 Bit Analog Output.

Alternatively, I can use an Arduino MEGA with the shield and the TMRpcm library: https://github.com/TMRh20/TMRpcm/wiki

I've saw that there's a sample with SD card and I've fiddled a lot to get the USB Host Shield 2.0 library to work and succeeded. However I've found a simpler implementation of it in the UsbFat library: https://github.com/greiman/UsbFat

Now basically I need to connect between these two libraries but sadly I've failed to understand how to convert "play_sd_wav.h" to use the UsbFat Library.

Or, more simply put, how do I command a USB pen drive like it is a SD card and pull an audio file from it?

Anyone can help please?

Thank You,

Ziv


texts: Grounding for arduino, measuring phase controllled 240V

texts:
I would like to measure a phase controlled 240Vac waveform as a digital PWM input for an arduino. The signal would look something like this:

My intent was to use a zener clipping circuit to limit the positive portion of the waveform to 5V, and measure that signal. However, I want to make sure I'm properly grounding these items. This is what my proposed circuit looks like, with all components inside a metal chassis.

I feel like ideally I would isolate this waveform from the system controller/light with a 1:1 transformer, but I'm unsure if that is feasible given its irregularity. Can I safely connect the arduino ground to the system's neutral, or am I barking up the wrong tree?

Thanks!


texts: Can I measure the current (mA) of my project with just a multi meter?

texts:
I have a project and wish to choose the correct battery back for it such that it will last the required amount of time between each recharge of the battery pack. I am using an Arduino Duemilanove with various attachements and shields.

I can measure that the draw on the project at the point the USB connects from my PC to the Arduino board (by attaching the multimeter to the Vcc and GND solder points on my Arduino board) which reads 5V DC as expected. Is there a way I can meausre the current (without any additional equipment) ?

I suspect somehow using Ohms law and measuring the resistance between two points would be the answer (knowing the voltage is 5V) but I can't work it out (as in where to measure) with my lack of any electrical knowledge.


texts:
I've been doing some Googling for GSM shields and their prices and frankly I don't understand why they are so expensive on average.

The official one sold by Arduino is 71 euros for me (I live in Europe), and third party ones have similar prices.

A cheap dumb-phone is usually 30 euros and those phones have become really impressive these days, they have even a camera. When they are locked with the carrier the price can go as low as 20 euros. How is it even possible that a single part of what is supposed to make up a phone is more expensive than the phone itself? :(

Thanks in advance!


texts: Why is my arduino acting like a radio? And is there a way to abuse this?

texts:
I am playing around with an arduino and a cheap SDR dongle and I just noticed something strange!

When I play a tune on pin 13 with just a random piece of wire connected to the pin (Using the Melody example from the arduino page: http://www.arduino.cc/en/Tutorial/Melody)
I can pick it up as AM sound on my SDR on exactly 64Mhz even as far as 15meters away through walls with a little gain!!!

What magic is going on here and secondly and maybe most importantly would there be a relatively easy way to pick up the signal using just an arduino and cheapo components?

(Just for educational purposes of course, I know that there is better options depending on what I need to send)

I would like any qualified guess as to what is going on, I am genuinely puzzled...


texts: Using an Arduino to drive a digital RGB LED strip

texts:
I recently purchased a 5M strip of digital RGB LEDs, that is compatible with the "Adafruit_NeoPixel.h" library.

Is maintaining the original order of the LEDs important?  Could I cut the strip in say four sections, and then reconnect those sections out of their original order?

Just to be clear these are digital 3-pin(+5V,DI,GRN) strips, not analog 4-pin(+12V, R, G, B) strips.

I'm just not finding good info regarding if the individual LEDs are pre-assigned an ID by the manufacturer, or if they somehow use a serial-timing way to assign IDs at startup.

Before digging through the Adafruit_NeoPixel.h, I wanted to see if I could get a quicker answer here.

THANKS!


texts: Blew my arduino pro mini s4 named component

texts: While working on my project I supplied 12v to my pro mini through raw input and then a s4 named component smoked and my pro mini  stopped working . It didn't turn on either through vcc or raw. The voltage regulator seems completely fine. Can I repair my pro mini. Please help.


texts: How do I calculate sampling rate of external ADC?

texts:
I am wondering if someone could explain this to me.

I want to calculate sampling rate of external ADC.
I am using ADS8320 which has max sampling rate of 100kHz, with Arduino MEGA 2560.
SPI divider is set to 128, which makes SPI frequency 125kHz.
Baud rate is 115200 (I am not sure if this is important).

Thanks a lot!


texts: Is NVS storage reset during an OTA update? (ESP32)

texts:
I plan to save some settings in the NVS repository of my ESP32, which will also be implemented OTA update.

The question arose, will the data in the NVS storage be reset when the OTA update is launched?


texts:
I have a Freetronics Etherten and am trying to use the NFC Shield - both the board and shield are trying to use Pins D10,D11,D12,D13

So my question - Is there an elegant way to have these two work together.  This really applies to any combination of shield with conflicting pins.  I'm thinking maybe use some in between headers or M/F jumper wires?

Is there a neat way to do it?


texts: Accessing raspberrypi.local from Nodemcu

texts:
Currently I am trying to access a rest API from NodeMCU. The API is hosted on my local LAN on a Raspberry pi 3 b. The Raspberry pi is accessible on LAN using the raspberrypi.local domain address.
But the problem is I am unable to access the raspberrypi.local address form NodeMCU.
It is unable to just resolve the address.
Can anyone please help me resolve this issue?


texts:
im using arduino and im out of pins.

I need something like a decoder but the problem is that the decoders only change one output pin I.E. for 0011 the output will be 0001000000000000 what i need is to have the first outputs on I.E for 1000 the output will be 111111111000000000 i basically need to light up to 16leds and im out of pins so i was wondering is there is any IC that does this for me if i have 1111 it will output 16 ones.