Possible to receive only with Arduino Serial? - arduino

Is it possible to run a serial port (soft or hardware) that only reads? The examples I see all involve two pins for read and write. I would like to use the TX pin for something else.

Here is a version of the SoftwareSerial library with the TX parts gone:
https://github.com/jbeuckm/SoftwareSerialIn

Related

Changing Wire library's Hardware I2C pins for custom arduino

I am trying to change the wires i2c pins to 11,12 (SDA, SCL). I built my own PCB but do not have the i2c lines in the same location. I used adafruits feather52 bootloader.
I found online that changing the variant.h file changes the i2c lines, but I don't have that file on my computer (PC), although my mac does.
I have tried the Wire.begin(SDA, SCL) though that's for the esps
I also tried to edit the wire.h files in both the default wire under C/programs/Arduino and the one under user/AppData/Arduino/adafruit though I haven't found where the pins are set.
The hardware packages are istalled into the Arduino15 folder. The location of the folder on Windows is in users home directory in C:\Users\\AppData\Local\Arduino15\packages.
The variant file is in variants/feather_nrf52832/variant.h
The nRF52 MCU can use any pair of pins for I2C.
So try to change in variant.h
#define PIN_WIRE_SDA (25u)
#define PIN_WIRE_SCL (26u)
to pins you need.
If it works, consider to define your own hardware definition instead of patching the variant.h.
You can't change the hardware I2C pins. They are hardware. That means that they are physically connected inside the chip to the part that drives the I2C. You can use a software I2C to "bit-bang" your communication. But that won't use the regular wire library.
You have a solution though. I was facing the same problem two years ago, and what I ended up doing was using software I2C. It "Bit Bangs" the I2C protocol on any digital pins of Arduino. There are couple of libraries for that. For example, check this one:
https://github.com/Testato/SoftwareWire
Start reading about I2C protocol and try to understand what the library is doing. Then it is possible to simulate the I2C protocol on the GPIO pins you have hardwired
You don't need to change NOTHING to use the Adafruit_SSD1306.h library.
If you're using a generic chinese OLED display, your problem is its address.
By default, the address of the 128x64 is 0x3D and if you have a 128x32 one the address is 0x3C, but chinese displays uses 0x3C on both sizes.
So look up for the line
#define SCREEN_ADDRESS 0x3D ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
and change it for this:
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Then, on your setup function, add Wire.begin(SDA_PIN,SCL_PIN); line replacing SDA_PIN and SCL_PIN with the pins you want to use, adding D before the number, like this:
void setup(){
Serial.begin(115200);
Wire.begin(D3,D4); //To use D3 as SDA and D4 as SCL pins, for example.
those are the only changes you should do. Tested on chinese generic display and NODEMCU made by AMICA.

Software Serial in avr

I need two RX and two TX pin in my program.
In arduino with "SoftwareSerial" easily I can make several RX and TX.
how to make it in avr(make two rx and two tx port)?¿?
Two ways for you:
Add #include path for g++ (must be c++ since Serial is a class).
Then just include the header as you did in Arduino.
Refer to AVR306 and device datasheet (I don't know what your MCU is) to learn how to use USART.
The first is easier and more convenient while the second is more flexible.
I would recommend including the Arduino libraries and just including SoftwareSerial as a one of your libraries because the pins_arduino.h file will take care of the mapping for you. However if you don't have the right pins_arduino.h for your AVR I would recommend looking into this git I made for this issue. I adjusted a lot of the code from SoftwareSerial.
https://github.com/joshagirgis/AVRonly-adjustedRecieveOnlySoftwareSerial
My issue was I wanted to use an atmega644pa with a software serial port but only receive the data. Note: it is much harder to read the data, software serially, than send it (bit banging). I had it receive only because I only needed to read commands from a GPS. The pin must be an interrupt pin.

Use the Arduino Nano's serial interface to communicate with ESP8266 -- currently hangs

I have designed a ledstrip driver capable of receiving commands over UDP-IP. I initially worked with an Arduino MEGA, and currently I'm in the process of deploying the code in an Arduino NANO.
The Arduino NANO only has one hardware serial interface, unlike the MEGA, which has several. This forces me to disable the usual debugging through one of the Serial ports (by sending strings to the computer) and to reserve the one and only serial interface for the ESP8266. In short, I am connecting the ESP8266 to the TX and RX pins in the NANO.
I am aware that I could use the softwareserial.h library, but I'd like to avoid it if possible.
The following function sets up the Wifi object:
void wifi_setup(){
// Initialize serial for ESP module
Serial.begin(9600);
// Initialize ESP module
WiFi.init(&Serial); /* GETS STUCK HERE */
...
}
The problem is: the microcontroller gets stuck in the Wifi.init() function and never abandons it.
I am aware that the serial interface is connected to the USB port, and am suspicious this might be a problem. However, I have tried giving power to the NANO through the VIN pin instead of through the USB port, and it hasn't worked.
What am I doing wrong?
The best solution will be to write separate code for ESP8266 and Arduino Nano - or even only for ESP8266 (NodeMCU to make it easy). It will be much easier. But if you really want to do it in your way, i think ESP uses 115200 baud, and you've set it to 9600.

How to give AT commands to HM-10 using hardware RX/TX pins of arduino uno?

I have been successful in using SoftwareSerial to pass AT commands to an HM-10 module. But, I want to use Hardware Rx/Tx pins (Digital pins 0/1) to do the same. Is there any library available for this purpose? Or, how do I achieve this?
You can use the hardware serial, but I advise you not to.
Rx/Tx pins are shared with USB to serial, so you cannot use the serial-monitor or upload to the Arduino without disconnecting your HM10.

Pin reading between arduinos

I'm working a little project where I make my own version of serial communication between 2 arduino megas using their digital I/O pins.
So there are a couple digital pins on arduino A that are set as output. These are plugged into two digital pins in arduino B which are set as input. Is there a way for arduino B to detect whether the output pins coming from arduino A are high or low?
I know this can be done with transistors, but is there a way to do it without them?
The digital pins from one Arduino can be connected directly to the digital pins on the other - no need for any transistors in between. Make sure there is a common ground between them so both boards are at the same reference level (connect the GND pins, or power both from the same supply).
You can read the digital pins on the receiving end by calling digitalRead(), and write to the digital pins on the sending end by calling digitalWrite(). Whatever protocol you implement will need to detect the high/low transitions and decode them accordingly.
I guess I'm curious why you wouldn't just use the built-in serial ports to communicate, unless this is just a learning exercise? Certainly worthwhile for learning, but unnecessary extra work otherwise...

Resources