New answers tagged

0

"It can store values for a long time" - that's not exactly what an eeprom does, the major property is that the information in the eeprom persists during power cycles and chip resets. In contrast, a RAM looses all information when you unpower the chip. To get a feeling for eeproms, I suggest you follow the below routine: 1. Upload this sketch: #include "...


3

The first slaves will be plugged in and will send to the master his default address If this happens while the master is talking to one of the other slaves, you risk a collision. I suggest a very small variation on your scheme. Each slave has a default address (0xff). When you turn it on, it doesn't say anything. The slaves only talk when they are ...


1

In short: Once you shutdown an Arduino, every variables on it, which have been calculated by the sketch, are lost. That is because they are stored in RAM, which is not able to store things without power. That is not the problem of EEPROM: values stored there will be available on reboot, and won't need to be calculated again. This can prove useful is your ...


0

The example in your question demonstrates the two functions, not a meaningful use of them. I made a kitchen timer. It uses the toneAC library. The toneAC library has a parameter for the volume of the sound. I made it available for the user to set the volume in settings mode of timer's display. I want this setting to be remembered if the kitchen timer is not ...


1

The problem here is that Serial.parseInt() stops when it sees the newline, but it does not consume that newline, which is left in the input buffer. Thus, at the next loop iteration, Serial.available() returns true because of this newline and, unless you send another value fast enough, Serial.parseInt() times out and returns zero. The easy fix is to consume ...


1

Hardware vs Software Serial: Most microcontrollers/Arduinos have at least 1 hardware Serial interface. That means, that for this Serial interface the actual communication protocol (the transmission and receiving of the actual data) is implemented in dedicated hardware inside the microcontroller (which also means there are fixed pins, where you can connect to ...


0

Hardware serial uses pins 0/1 on the Uno. You can't change those pins. Those pins are also the pins that are used to communicate with your computer. You can use hardware serial on those pins to communicate with the HC-05 only if you don't want to communicate with your computer. SoftwareSerial can be used on any pins so can be used at the same time as the ...


1

You have a misconception about the interfaces involved. Actually we have 2 different interfaces here: Bluetooth and Serial (UART). The HC-05 is a Bluetooth Serial bridge. The Bluetooth interface has a fixed concept of master and slave. Every connection needs to have only 1 single master. This concept applies only to the communication between HC-05 and the ...


0

You are overflowing your buffer, and also allowing garbage reads. First you need 5 bytes for your buffer not 4, and you need to ensure it is zeroed out before using it. This is because you are treating it like a C string, which means it must b zero terminated. Secondly your use of Serial.readBytesUntil() is flawed. From the manual: The function ...


0

You could use a logic level MOSFET with low RDSon (e.g. IRLZ44) to switch the supply of the HC-05 and use a digital pin to control it.


-1

Over a serial port, you are transmitting data byte by byte. If you want to interpret them as numbers, you have to parse the data and assemble the numbers yourself. You could resort to BLE instead, there you may transmit strings and numbers.


1

The schematic is totally working. My mistake was after burning bootloader, I was uploading code via ISP. If you upload code via ISP, you're removing bootloader. Thank you everyone who helped me to I wasn't mistaken at schematic and else...


-1

You need a logic level translator of some form (such as a resistive divider) if the Arduino runs at 5V. If it's a 3.3V Arduino then you don't need one since the logic levels will match. You connect to the TX and RX pins (or TX1/RX1 etc) of the Arduino if you want to use a hardware UART (Serial, Serial1, etc). You connect to any pins you like (with certain ...


-1

While you should use a voltage divider on the Arduino TX --> BT RX signal, you honestly don't need to. Many people, including myself, have used HC-05s without voltage dividers and haven't let "the magic smoke" out of the device. Adding a voltage divider may, though, may increase the lifespan of the HC-05.


0

From the scope picture it appears you have a ground problem. All the grounds must be connected together even the scope. It appears like you have a pseudo phantom ground via the mains power system. Did you set the baud in the uno with Serial.begin(your baud rate);? The baud must be the same on both ends. For a check you should get a UNO and see if it works ...


0

You can write your own python script that prints received serial output. By using try/except in a loop you can "pause" your serial monitor while uploading is in progress. I did the same a while ago using pyserial on linux. I'd like to share it, but at the moment I have no access to my other machine. I can post it later if you want.


0

#include <WiFiEsp.h> #include <WiFiEspClient.h> #include <SoftwareSerial.h> ... SoftwareSerial wifiSerial(WIFI_RX, WIFI_TX); WiFiEspClient WIFI_CLIENT; ... void setup() { wifiSerial.begin(9600); // or 115200 WiFi.init(&wifiSerial); if (WiFi.status() == WL_NO_SHIELD) { printLog("WiFi shield not present"); // don't ...


1

Set the blocking timeout to 0 with: tty.c_cc[VTIME] = 0; tty.c_cc[VMIN] = 0; This way, you don't bother waiting in read() for data to come in: just grab what's available, print it and keep moving. Then include time.h and try re-writing your loop like so: while (true) { // Read bytes. The behaviour of read() (e.g. does it block?, // ...


2

The interrupt on pin 2 triggers, because the pin is floating. Since nothing is connected to the pin, it reacts to whatever noise is flying by (for example from pin 3). That can lead to the pin changing its state together with pin 3, or to just erratically randomly changing state. You need to connect a pullup or pulldown resistor (one rather big resistor ...


0

As explained by Majenko's answer, you should detect the pulses from an interrupt and print the result from the regular code. However, instead of just setting a flag in the interrupt handler, I suggest you instead count the pulses within the handler. This will make the handler a tiny bit slower, which is often something you want to avoid. However, the extra ...


0

It depends where the signal comes from and on other code in your sketch. Typically, a sketch is rather way too fast for a mechanical switch, and you have to debounce it. If your fear to lose events is realistic, interrupts are the way to go. But an ISR is some very special code: You won't do more than collect the information that there was an event. And ...


0

This is exactly the reason interrupts were invented. They can respond a lot faster than a simple digital read. By "a lot" I mean orders of magnitude. When an interrupt is triggered your interrupt handler for that interrupt executes. If another interrupt occurs whilst your interrupt handler is running the interrupt controller remembers it and the interrupt ...


1

As soon as I connect up the battery, I loose the Serial Monitor connection (even though the USB cable is still connected). So I can no longer see what's going on inside the Arduino for debugging purposes. Why? How can I continue to see the Serial Monitor? Is there a way to see the serial output from somewhere other than the USB jack? Probably because ...


Top 50 recent answers are included