Hot answers tagged

20

I did not knew I could change the port on windows. This is how I did it thanks to @Majenko's comment.


10

It's not the data type, it's the printing routine that sets that limit. In Print.cpp: 227 if (isnan(number)) return print("nan"); 228 if (isinf(number)) return print("inf"); 229 if (number > 4294967040.0) return print ("ovf"); // constant determined empirically 230 if (number <-4294967040.0) return print ("...


8

In short, you don't. The SoftwareSerial implementation for AVR doesn't have an outbound buffer at all. It just turns the interrupts off during each character outbound and it sends them all immediately. This means a call to SoftwareSerial's write simply will block until all of the data you've tried to send has in fact been sent. If you can't afford to wait ...


7

Important information: Wire.write() does NOT send anything over the I2C lines. It just puts the data into the libraries internal buffer. The actual transmission is then done by Wire.endTransmission(). I2C is packaged transmission protocol. That means, that the transmission is done in confined data packages. In your master code you are calling Wire.write() ...


6

There is an open source project that will do what you want. http://com0com.sourceforge.net/ The com0com will create virtual com ports for the programs to connect to. The hub4com will allow you to route data between the physical port and multiple virtual com ports. http://com0com.sourceforge.net/hub4com/ReadMe.txt


6

I was going to put this as a comment, but maybe it belongs as an answer: For what it's worth, ArduinoJSON seems to be able to deserialize directly from a stream, i.e. Serial, which may obviate the question as asked. Presumably it knows where to stop deserializing, because it knows when it has received an entire JSON object; being a proper JSON parser, it ...


6

Serial.write(some_byte) writes a byte on the serial output. The Arduino serial monitor tries to interpret the bytes it receives as text: 0x11 is a control character, displayed as “□” 0x22 is the ASCII code for the double quote (") 0x33 is the ASCII code for the digit 3. 0x44 is the ASCII code for the uppercase letter “D” etc.


5

I mean where would you expect it to print Hello World ... On the Serial Monitor, right? So first open it by clicking on the Serial Monitor button at the bottom of the code tab in Tinkercad. I tried your code and it works perfectly fine.


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 ...


5

You can have bidirectional communication over a single wire by using open-collector outputs. For this, you could add a circuit like this on each side of the link: simulate this circuit – Schematic created using CircuitLab Here, TX is the transmit pin of the Arduino, and DATA is the data wire. The RX pin is connected directly to the data wire and, ...


4

There are a few issues at play here. One is that the Arduino resets every time you open the serial connection on the PC side. You can prevent this by putting a 1 µF (or more) capacitor between 5V and RESET. A second issue is that the tty driver may be keeping old data in its buffer, and you get this data when you open the connection. The third issue is that ...


4

There is something wrong with some new kernels of Ubuntu 20.04 LTS, interfering with ESP8266 core uploading process 5.4.0-88-generic #99-Ubuntu SMP Thu Sep 23 17:29:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux I had the same issue and downgraded the kernel to 5.4.0-86-generic #97-Ubuntu SMP Fri Sep 17 19:19:40 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux solved the ...


4

First of all, I will challenge your assumption that you have to send the three bytes in the same call to Serial.write(). There is no real advantage in doing so. Serial output is handled through a memory buffer that is consumed by the serial port within an interrupt service routine. Serial.write() only writes to that memory buffer. Thus, you can simply: ...


4

You should learn how to use bitwise operators. These are needed to do what you want. We can save the state of each switch in one bit each. For this we first define our global variable that will hold the switch states: byte switch_states = 0; Then in getLimitSwitch() we loop through our pins. The result of digitalRead() is always one of 0 and 1. So we can ...


3

If your goal is to "talk" to a computer vs. a human, then a format that can be parsed easily is better than one that is easy to read. For example, you have: I received: 255 I received: 247 I received: 11 I received: 0 While this could be parsed by your Uno, it will be a lot simpler if you send the data something like: 255|247|11|0 Now you can use ...


3

Building on @snakeNET's answer (which I regard as function overload rather than polymorphism)... A more generic way would be to pass in a pointer to Print, allowing any Print related class to be used (not just Serial); also pass objects by reference e.g. void types(Print* p, const String&) { p->print("it's a String"); } // for each type ... ...


3

I have tested your code. There appears to be defective clones of the nRF24L01 around that exhibit an issue I show in post nRF24L01 continuously reading closed pipe You can work around this issue by changing your code as follows (although your process still has to read all those nulls): void getData() { uint8_t pipeNum; if ( radio.available(&pipeNum) )...


3

Your problem is, that you try to provide a HEX value, but you are actually providing a decimal value. When you just write a whole number like 32, it will be interpreted by the compiler as a decimal number. The decimal number 32 is equal to HEX 20, which is a space character in ASCII. Solution: Write your number as decimal value like this: int i = 0x32; The ...


3

The SSD1306 uses a lot of RAM. Pretty much all your RAM. Serial also uses quite a bit of RAM. The two struggle to work together. There is a special "text only" SSD1306 library that uses considerably less RAM: https://github.com/greiman/SSD1306Ascii


3

I figured out why while(Serial.available()>0) and if(Serial.available() > 0) would or would NOT work in terms of my shift register code. It has to do with the serial monitor line feed and carriage return setting! If it isn't set to no line ending, it will either not register the input number or reset it back to zero right after the input is read. ...


3

I don't actually know what a UART is UART (Universal Asynchronous Receiver Transmitter) is the technical term for the communication interface, which is called Serial in Arduino speak. It's often called UART, because that is more precise, since there are many different communication protocols, which also work serially (meaning transferring data bits one ...


3

On a Nano you can #include <avr/sleep.h>, then simply call sleep_mode() from loop(). This will put the device to sleep, by default in IDLE mode, until the next interrupt fires. The Nano will wake up at least once every 1,024 µs, to service the timer interrupt that is used to implement the Arduino timing function(millis(), delay(), etc.). Most of the ...


3

You wait for user input with a while (Serial.available() == 0), the you read the input with Serial.parseInt(). parseInt will wait a second for digits. It will end on a non digit character or timeout and return the number corresponding to received digits. If no digits were received a 0 is returned. Serial Monitor has Line end setting. If there is some line ...


3

The Sparkfun RS232 shifter is not a great device. It relies on whatever it's connected to (on the 9-pin port) providing the negative rail for the EIA-232 voltage levels. That's fine when you connect to something that has those voltages available, such as a computer, but many "devices" don't - they will themselves have a similar shifter inside and ...


3

As regards the use of Stream: I usually use Stream instead of HardwareSerial because: It allows the use of other serial devices, like SoftwareSerial or USBSerial that aren't "Hardware" UARTs. It even allows the use of non-serial systems, like sending data over networks or wireless devices However it means: The user has to manually initialize ...


3

This question likely suffers from the X Y problem. Where the question (about software) and possible answer (centered on hardware) do not approach the solution using the same methods. The question is essentially asking how to design a 1-wire interface over longer than normal distances. There are 1-wire Arduino libraries and 1-wire Arduino tutorials. But it ...


2

My solution - install linux-modules-extra kernel module on ubuntu 20.04. Solved my problem which was identical. Get OS details: uname -a Linux seeeduino-node 5.4.0-91-generic #102-Ubuntu SMP Fri Nov 5 16:31:28 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Install the sudo apt install linux-modules-extra: sudo apt install linux-modules-extra-<kernel-version> ...


2

On macOS, you can use the built-in screen command, e.g.: screen /dev/cu.usbmodem14201 9600 To exit, control-A followed by control-\


2

Arduino uses the DTR line (data terminal ready) So, with the Arduino Serial Monitor it is not possible to change the restart when established the rs232 connection. But I'm using for example the freeware "HTerm" (under Windows). By default, it does not use the DTR signal. Meanwhile I changed to the freeware "CoolTerm" (a bit more ...


2

In case someone does ask the same question in the future, this is the explanation for the USB/XBee switch functionality on the XBee Pro Shield V3 The switch serves to connect/disconnect the XBee Pro shield v3 to the Hardware TX->1 & RX<-0 Lines of the Arduino. Moving the switch to the USB side, allows you to disconnect the XBee Pro shield v3 from ...


Only top voted, non community-wiki answers of a minimum length are eligible