New answers tagged

4

The ESP32 has more than enough free GPIOs to manage those peripherals. Also, the ESP32 does indeed come with a bluetooth module. Your question about powering these peripherals very much depends on their power requirements. I would not count on being able to run motors or servos from the internal power supply of a NodeMCU board, so you would need an external ...


0

A simple and effecient way is to use relative days and make use of the fact that the days, hours, minutes, and seconds are byte-sized data types that can fit into a single 32-bit data type. byte 3 byte 2 byte 1 byte 0 Day Hour Minute Second This can be achieved with the following function: constexpr uint32_t MakeTimestamp(const byte day, const byte hour, ...


1

A) do I have to remove any of the plastic casings that I have highlighted in order to make the motors move. Those aren't "casings", those are diodes. They are part of the circuit and must be left alone. B) What is the purpose of the black plastic casing that I have pointed out? That is a "jumper" and is used to connect the +5V pin to ...


0

The uno pins are 3, 5, 6, 9, 10, 11. See https://www.arduino.cc/reference/en/language/functions/analog-io/analogwrite/ Usage: analogWrite(pin, value);


5

I don't know anything about the particular display, but based on the information provided I hope this is at least shows the foundation of one way you could approach a final solution. Update: Incorporated great improvements and a fix from Edgar in the comments. String overload. Display baud rate suggested by mehmet #define DISPLAY_DEVICE Serial #define ...


2

Here are two functions that I hope help in your endeavours. You can supply either a String or a char array and you should get the first position of an alpha character. Returns -1 if not present. See https://www.arduino.cc/reference/en/language/functions/characters/isalpha/ Update: Thanks to great comments from Edgar & Mat I have updated the functions ...


1

Is there any way to program [a bare AVR microcontroller] without Arduino [IDE software] or AVR [software development toolkit]? I believe you can use A text editor of your choice to create and edit source code files. The GNU compiler GCC-AVR to compile source code into machine-code. The avrdude program to install the compiled code onto the microcontroller. ...


1

You can use the watchdog timer, but you have to change the way you measure the elapsed time. Try this code: #include <avr/wdt.h> unsigned long myTime; // Millis() function time value unsigned long elapsedTime; unsigned long timeExpected = 5000; // I want to reset it in every 5 secs for testing. const int RESET_PIN = 2; // Reset pin's connection void ...


1

You can do an almost immediate full reset with watchdog by activating it 'on place'. wdt_enable(WDTO_15MS); // resets the MCU after 15 milliseconds while (true); You can use millis() for timing the reset as any other timed function.


7

The short answer to your question is “yes, there is a way”. Multiple ways actually. You could write a blocking function, which follows more or less the logic of the example you show, blocking while waiting for each new byte. Or you could write a non blocking function, which always return immediately and, either gives you the complete packet, or tells you ...


0

You are using the wrong pins on the SIM900A to communicate with your Arduino. That specific module has a MAX232 interface on it to convert TTL UART to RS232. That is not compatible with the Arduino unless you add another MAX232 to undo the conversion that the one on the board does. Instead you need to use the other 3-pin header at the other end of the board. ...


1

Here's the final form of my project. I've added motor detach function since it still shivers a bit. #include <SoftwareSerial.h> #include <Servo.h> const int MPU_addr=0x68; // MPU-6050 I2C address int16_t AcX,AcY,AcZ,GyX,GyY,GyZ; SoftwareSerial BTSerial(3, 2); // TX, RX Servo servoMini; Servo servoUp; Servo servoDown; const byte pinMini = 6; ...


1

Is there other way to get acceleration directly? or Do I have to use formula(v = v_0 + a*t)? The code appears to be currently retrieving the raw X, Y & Z acceleration and storing it in AcX, AcY & AcZ. The equation "v = v_0 + a*t" appears to be deriving velocity. So the question is confusing. ...for the gyro sensor, I can't understand ...


2

A while ago while figuring out I2C difficulties of my own I did some research and listed out all the failure modes and test techniques I could think of regarding I2C. See I2C protocol doesn't work properly. I routinely go through the list now to tick off the things I need to check to get a new I2C connection working, usually it's something simple (...


1

From the MPU-6000/MPU-6050 Register Map and Descriptions: Section 4.28, Register 107 – Power Management 1 PWR_MGMT_1, pages 40 to 41: Note: When using SPI interface, user should use DEVICE_RESET (register 107) as well as SIGNAL_PATH_RESET (register 104) to ensure the reset is performed properly. The sequence used should be: Set DEVICE_RESET = 1 (register ...


2

You have two problems with your code: byte is equal to unsigned char and can only hold exactly one byte, aka 8 bits (not 16 bits like your comment says). But you are trying to assign a 16bit number to it. The upper 8 bits are cut out in that process. They are lost. If you want to hold a 16bit number, you need to use a data type, that is at least 16 bits in ...


1

The function shiftOut() only works for 8-bit values, as its documentation says. Additionally, a byte can only store 8 bits. It doesn't matter how many bits you try to assign. (The compiler should have given you a warning, but the IDE likes to hide this.) You need to write your own output function to shift out 16 bits, AFAIK.


0

This is the best I can get to work with 6 available pin change interrupts - just enough! #define EI_ARDUINO_INTERRUPTED_PIN #define EI_NOTPORTB // DISABLE FOR LMIC #define EI_NOTPORTD // DISABLE FOR LMIC


0

A small update to your code Added lcd.begin(); function added lcd.clear(); function so that old characters will be removed before adding new display Here is the complete code int red = 10; int yellow = 9; int green = 8; #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); pinMode(red, OUTPUT); ...


3

You have written your question beautifully. In your case, according to your logic, the button has to be kept pressed, so that the LEDs are lit in the order you desire. The single loop() function is part of the Arduino sketch but it is never a limitation. One way to solve your problem is to make the LED drive logic independent of the button press state. Once ...


5

By using delay() it blocks the rest of the code. The programme needs to keep track of two buttons and update the lightshow at appropriate times, therefore a non-blocking style of coding is needed similar to the Blink Without Delay example where the delay() is replaced with a timer using millis() that is checked periodically. This allows other things to be ...


2

You simply need to save the state of the LEDs in a new variable ... void loop () { if (digitalRead(buttonON)== LOW) ledEffectON = true; if (digitalRead(buttonOFF)== LOW) ledEffectON = false; if(ledEffectON) { delay(300), digitalWrite(LED1, HIGH); delay(50), digitalWrite(LED2, HIGH); delay(50), digitalWrite(LED3, HIGH); ...


1

Hello I had the same problem and noticed that if you setup the lcd screen in this order: LiquidCrystal lcd (d7, d6, d5, d4, , en, rs) ; you get some weird character showing up... but if you do this way: LiquidCrystal lcd (rs, en, d4, d5, d6, d7) ; you don't get any weird character.


2

As I understand it you have a multiplexer with one of the inputs connected to 5 volts and the rest are open. What you are reading is leakage in the IC and associated wiring. There are many reasons they tell us not to leave inputs open, you just found one. This is especially problematic with CMOS devices because of there extremely high impedance. The first ...


1

I don't know what the time.sleep(4) statement fixes, but you could try moving the to the top of the loop instead of the bottom, so it precedes the first read. At the bottom of the loop, it's first execution comes after the first read.


1

You might want to try sending the data in a packet delimited by unique characters, e.g. { and }, similar to the JSON format. The NMEA GPS standard uses $ and '\n' to delimit messages. Here is an Arduino non-blocking C++ algorithm which builds upon Majenko's readline() example to read a packet. It returns true when incoming data has been accumulated into a ...


0

Answer: Make sure you install the right library :P


1

It is not working because of: SPEED Consider the frequency of the 433Mhz device vs. the speed of the serial monitor. The device sends signals with pulse width in the range of tens of microseconds while the serial monitor can't display that fast. Your code should analyze the signals, clean the noise (the output of the device is very noisy) and figure out the ...


1

I think you want something like Blink Without Delay, but with more tasks. Here is my interpretation of your description which extends Blink Without Delay by adding three more tasks to: read the accelerometer perform "just once" perform "also just once" I've added several Serial.print() statements to give a running commentary on what's ...


2

You will save yourself a lot of headaches by sending the data in ASCII instead of binary: bluetoothSerial.print("RMSCurrent: "); bluetoothSerial.println(RMSCurrent); Of course, you will then have to parse the data stream on the Python side. If you really want to send binary data, then be aware that the write() method you are using is intended for ...


0

The hardware serial, pins 1 and 2, are used by the Arduino to communicate to the USB adapter to your computer. When you connect another device to them, it interferes with the communication between your computer and the Arduino. The solution is to connect the ESP-01 to another set of pins and use the SoftwareSerial library to create a second serial port for ...


1

I’m new at this but looks to me like your rtc is uses i2c comms. I don’t see that you’ve included wire.h or issued the wire.begin to initiate communication between the rtc and arduino. See other rtc examples and good luck!


1

You are pushing the limit of the L298N, probably will exceed it. A typical stepper motor like a NEMA 17 is probably rated at voltage of about 2.8 Volts and a maximum current of 1.68 Amps. This basically means if you hook it up to 2.8 Volts it will draw 1.68 Amps. If you try to run it at a higher voltage it will draw more current and get excessively hot. ...


0

I believe the issue is that you're setting your encoder pins high with digitalWrite(). Those pins need to be configured as inputs for the interrupts to work correctly. This will be handled by the encoder library when you call r.begin(true). In fact, true in that call tells the library to enable the pullups for you. Removing those lines should fix your ...


3

I2C is a multi-drop bus. That means that one set of I2C pins are designed to have multiple devices on it as long as each device has a unique address. On an Uno the discrete I2C pins and the A4/A5 I2C pins are the same pins. The discrete pins are an attempt to provide a cross-platform standard location for the I2C signals for shields.


1

Here is a general idea of a MOSFET alternative for switching the light on and off. Click to simulate in Falstad. You can click the switch and the H/L input to see how it operates while running the simulation. The p-channel MOSFET in series with Light 1 could be FQP27P06. The n-channel MOSFETs are of much lower power. Using MOSFETs eliminates both the RFI/EMI ...


3

There are two things to tackle in your schematic. First is snubber networks. These are used to aid in the prevention (or rapid extinguishing) of sparks between the contacts of switching gear (like relays). You should attach one across the contacts of each relay. It is these sparks that create most of the "airborne" EMI. A diode across a relay's ...


2

I know this problem from Arduino Uno clones. You need a proper driver. Here are a few: CH341 serial driver (e.g. for Vendor ID 1A86, Product ID 7523) Holtek UART bridge (e.g. for Vendor ID 04D9, Product ID B534) FTDI Drivers (e.g. for Vendor ID 0403, Product ID 60xx) CP210x Drivers (e.g. for Vendor ID 10C4, Product ID EAxx) Prolific PL2303 (e.g. for Vendor ...


1

Your key values are: int keyVals [16] = {976, 450, 333, 244, 166, 138, 124, 109, 90, 81, 76, 70, 61, 57, 54, 51}; The formula for the key values given in the OnewireKeypad library is: float V = (voltage * float( R3 )) / (float(R3) + (float(R1) * float(R)) + (float(R2) * float(C))); float Vfinal = V * ANALOG_FACTOR; where: voltage = 5 V R1 = 1,000 Ω (the ...


1

ESP8266 code : #include <ESP8266WiFi.h> #include <FirebaseArduino.h> // Set these to run #define FIREBASE_HOST "" #define FIREBASE_AUTH "" #define WIFI_SSID "Home " #define WIFI_PASSWORD "" int value1; String string_value; void setup() { //Initializes the serial connection at 9600 get sensor data ...


3

Cool I got it using avrdude. $ avrdude -c arduino -P /dev/ttyUSB0 -b 9600 -p m328p -U flash:r:CNCArdunio.hex:i > -c the platform (basically) > -P the port where your harware is. > -b the baudrate. > -p the chip architecture. > -U momory type flash :r option to read to file :i option to format into Intel HEX. caveats.Upon closer inspection ...


0

Your ESP needs to receive data from Firebase over WiFi; send the received data (or the useful part of it) to the Arduino, over its serial port. Your Arduino needs to: watch its own serial port for data becoming available; read the data; decide whether turn the LED on or off. Your loop() code on the Esp is watching its serial port, but from your ...


0

System State Machine As JRobert suggested, a state machine would make the code a lot cleaner! Below is some pseudocode (I'll leave the debugging up to you ;)) of how you might set that up. When you break up your system into 4 distinct states, it's easy to reason about what should be happening at each state and what is required to get to the next state. You ...


0

Assuming you're asking how debug the unexpected behavior your described (and not having any steppers on-hand to have a go at your code) I'll offer some observations and suggestions. Pushbuttons "bounce" (not really, but their output signal looks like they bounce). For the limit switches, you won't really care - the first make (and I'm assuming ...


1

Another way to solve this problem is using cronAlarm. It can provide precise control on timings and you can schedule your job also. https://www.arduino.cc/reference/en/libraries/cronalarms/


1

See this answer for an explanation. Using unsigned variables, and subtracting will definitely work. Not only will unsigned variables not become negative (by their very nature) but the rollover will be handled smoothly and accurately.


0

This happens because you are not reading from Serial. When you send data to the Arduino, it gets placed in the Serial buffer. Serial.available() then returns the number of bytes in the buffer. The bytes are removed from the buffer by Serial.read()ing them, which you don't do. Since you don't remove any bytes from the buffer, Serial.available() will always ...


2

Is there any print out based on this; Serial.print("Initializing SD card..."); // see if the card is present and can be initialized: if (!SD.begin(chipSelect)) { Serial.println("Card failed, or not present"); // don't do anything more: return; } Serial.println("card initialized."); Solution; Try change const int ...


1

Your SPI is not setup for the Arduino UNO. Check another example for SPI and you will be using pins 11 and 13, this is mandatory and 8,9,10 or any three and there is a definition statement for these 3 pins - look at the example for your display. For I2C do you have pullup resistors on both I2C lines 4.7k up to 10k? These are required. Good luck


1

As @Majenko had pointed out in the comments, it was temp variable causing the problem. Or rather, strings in general seem to have a bad effect on the memory of the Arduino UNO. After I rewrote the code without using any strings at all, the problem was fixed and the program gave a consistent output.


Top 50 recent answers are included