Redpark Serial Cable Arduino iOS - ios

I've used the RedPark seriable cable with iOS before however, I've only been using it to receive data from an Arduino. My ambition is to be able to transmit information from the iPhone to the Arduino also.
At the moment it's set up to receive
Arduino RX -> Redpark TX
Arduino TX -> Redpark RX
Arduino 5V -> Redpark 5V
Arduino GND -> Redpark GND
The example I used was to toggle the LED on an Arduino board...
void setup() {
Serial.begin(9600); // Start the serial port
pinMode(13, OUTPUT); // Set the built-in LED to output mode
}
void loop() {
if (Serial.available()) { // If there's anything on the serial port,
byte cmd = Serial.read(); // read a single byte from it.
if (cmd == '1') { // If the command is the character '1',
digitalWrite(13, HIGH); // set the LED on
}
if (cmd == '0') { // If the command is the character '0',
digitalWrite(13, LOW); // set the LED off
Serial.print(cmd, BYTE);
}
}
}
I also used the accompanying iPhone app with the Redpark serial cable. I have confirmed I am able tor receive text (using the default app that comes with the RedPark serial cable. So I know that when the iPhone is connected to the Arduino, I am able to receive transmitted data from the Arduino. I can't however transmit any data (the default app allows you to transmit data + the app confirms that the iPhone has sent data. However I am unable to fall into this method on the Arduino, when sending from the iPhone.
if(Serial.available())
{
...
}
For reference, the iPhone I'm using is the iPhone5 with the 30 pin to lightning adapter.

Related

ESP8266 not working after baud rate change

Hello guys I have my ESP8266 connected to my Arduino. Then I typed in AT in the serial monitor. It confirmed this command with OK. After that I typed in AT+UART=9600, 8, 1, 0, 0 which gave me the response ERROR. Then I googled what I could do, which told me that I should try change the baud rate permanently with the command AT+IPR=9600. I did this but I got no response. After that I wondered if everything was ok so I typed in AT. No response. Now I'm a little bit sad because everything started to be great but I don't know how I can fix the whole problem. I also tried to upgrade its firmware with XTCOM Utility but it says it can't connect.
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX
void setup() {
Serial.begin(115200); // communication with the host computer
//while (!Serial) { ; }
// Start the software serial for communication with the ESP8266
ESPserial.begin(115200);
Serial.println("");
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("Ready");
Serial.println("");
}
void loop() {
// listen for communication from the ESP8266 and then write it to the serial monitor
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }
// listen for user input and send it to the ESP8266
if ( Serial.available() ) { ESPserial.write( Serial.read() ); }
}
This is my code. I tried it with both 9600 and 115200 but if I use 115200 the serial monitor just shows some garbage signs. It's kind of frustrating because I can't even interact with the serial monitor as my typed commands don't show up anymore. Do you have any idea how I could fix this problem?
EDIT:
I read that the command AT+IPR=9600 breaks the module and it can just be fixed by reflashing it. Sadly this doesn't work because it somehow can`t connect.

Unable to read serial/uart pins on NodeMCU

I am unable to read the serial pins in the NodeMCU Lua environment. I have only been able to read the USB serial port.
I have connected a serial adapter to the rx, tx, and g pins.
I have tried this code:
uart.on("data","\n",function(data) print("receive from uart:", data) end, 0)
I enter text in the ESplorer console and it does read that. It doesn't read anything I send over a serial adapter plugged into the rx/tx/g pins.
uart.write(0, "hello")
I disconnected the USB cable and powered it with the serial adapter. Nothing was sent using this code. I tried uart.write(0, and uart.write(1,.
How do I read the pin serial ports instead of the usb serial port?
I needed to unplug the USB cable. The device gets confused if the USB cable is plugged in and you're trying to use the pin serial port.
See my question on the esp forums:
https://www.esp8266.com/viewtopic.php?f=22&t=19768
You have to use different pins then the RX and TX as they are the same as the USB port you are connecting your NodeMCU with to your PC
You can use any other 2 free gpio pins as a serial port with the help of https://github.com/scottwday/EspSoftSerial library. This library is specificly for ESP8266 on which your NodeMCU is based.
This way you have 2 serial ports, one through the usb and another one to connect to other devices.
Some simpel code to implement the Software serial below.
#include <SoftwareSerial.h>
#define BAUD_RATE 9600
SoftwareSerial Serial2(D8, D7, false, 8); //Here you choose the pins you connect the RX TX device to
//The first pin you choose is RX the second TX
// in my example these are the D8 and D7 pins on the nodeMCU
// D8=RX .... D7=TX
void setup() {
Serial.begin(BAUD_RATE);
Serial2.begin(BAUD_RATE);
Serial.println(" ### Hello ###");
Serial2.println(" ### Hello ###");
}
void loop() {
}
}

Serial Communication of Sony Spresense with ESP8266 E12

I'm trying to create a simple serial communication between my ESP8266 E12 and a Sony Spresense. I have connected the Spre.RX with ESP.TX, the Spre.TX with ESP.RX and Spre.GND with ESP.GND.
Receiver:
byte rcvByte;
void setup() {
Serial.begin(9600);
while (!Serial) {;}
Serial.println("Receiving");
}
void loop() {
if (Serial.available()) {
rcvByte = Serial.read();
if (rcvByte == 'H') {
Serial.println("High");
}
if (rcvByte == 'L') {
Serial.println("Low");
}
}
}
Sender:
void setup() {
Serial.begin(9600);
while (!Serial) {;}
Serial.println("Sending");
}
void loop() {
Serial.print('H');
delay(1000);
Serial.print('L');
delay(1000);
Serial.println();
}
Unfortunately, nothing happens. I tried both, ESP as Sender and Spresense as Receiver and vice versa.
It works like a charm when I connect my ESP and a Arudino Uno, in both ways.
Do I have to enable the RX/TX pins with the Spresense somehow? I have tried the pins on the developer board as well as the small board directly. Any suggestions?
I took a quick look into this and my best guess, or tip after checking the code is to try the following on the Spresense side:
Simply change Serial to Serial2.
void setup() {
Serial2.begin(9600);
while (!Serial2) {;}
Serial2.println("Sending");
}
void loop() {
Serial2.print('H');
delay(1000);
Serial2.print('L');
delay(1000);
Serial2.println();
}
I have not tested so please do if you can.
I noticed a small detail in the hardware datasheet provided at:
Spresense Hardware Documents
In the section labeled - 2. Differences between Spresense and Arduino Uno:
It has a small table showing the comparison with explanations.
Located at the bottom of the table one can see the boxes for UART Serial communication.
Note the existence of two serial outputs on the spresense board. The Spresense Main board (smaller nano like) has a serial UART rx/tx pair with syntax variable -> "serial" but in addition the Spresense expansion shield also has a second UART RX/TX pair with syntax -> "serial2"
"The Spresense main board and extension board have UART terminals.
It is not possible to use the UART on both the main board and the extension board at the same time.
The extension board is configured to have the UART enabled when it is shipped. To use the UART pins on the main board when attached to the extension board, a 2.54mm pitch jumper have to be connected to pin 1 and 2 on JP10 of the extension board to disable the extension board UART. No jumper is supplied with the Spresense boards so this has to be purchased separately.
When the extension board UART is activated, the UART pins (D00, D01, D27 and D28) of the main board cannot be used as GPIO."
I ended up spending about three days pulling my hair out before i realized looking at documentation provides all the answers one could need..
The killer is in the details on this one.
This should provide some clarity to others experimenting with UART communication between spresense products while attempting utilize the expansion board.

iOS Application not Writing to BLE Mini

I am designing an application which will communicate with a TI LaunchPad through a BLE Mini by utilizing CoreBluetooth, however I am struggling to transmit data between my iPhone and the Red Bear BLE Mini. Currently, I am trying to send a command which will instruct the Launchpad to turn an LED on and off. I have implemented all of the CoreBluetooth methods and confirmed that I am connected to the BLE Mini. I also have discovered this device's singular service and the five characteristics associated with this device with my iPhone application, so I know I am connected to the device. After confirming this connection, I attempted to write to the write characteristic, but I'm not sure if I wrote to this characteristic properly. Also, I'm not sure how I should be encoding the data. I have tried both ascii and utf8. Here is what I wrote:
let string = "LED-ON"
let data = string.data(using: .ascii)
if manager.write_char != nil{
print("trying")
print(manager.write_char.uuid)
peripheral.writeValue(data!, for: manager.write_char, type: CBCharacteristicWriteType.withoutResponse)
The print statement confirms that this characteristic has the uuid that I defined as being the write characteristic
let WRITE_CHAR = "713D0004-503E-4C75-BA94-3148F18D941E"
I believe this is the correct write characteristic. I have also tried 71230003. On the Launchpad side, I have uploaded the following code:
int incomingByte = 0; // for incoming serial data
void setup() {
// put your setup code here, to run once:
Serial.begin(19200);
Serial1.begin(9600);
pinMode(7, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//if (Serial1.available()){
// Serial.print("available");
//Read in data
Serial.print(Serial1.available());
Serial.print(" ");
Serial.print(Serial1.read());
Serial.print("\n");
if (Serial1.available() > 0) {
// read the incoming byte:
incomingByte = Serial1.read();
// say what you got:
Serial.print("I received: ");
Serial.println(incomingByte, DEC);
}
}
In the serial monitor, all I receive are 0 from the available check and -1 from the read method both of which signify that no data is being received. Am I transmitting data to the BLE Mini correctly? If so, am I reading it incorrectly? Additionally, is there something I'm supposed to do to tell the BLE Mini to transmit data? Sorry for the long winded question. Thank you so much for the help.

WiFly shield + Arduino + auto-connect issue

I'm using the WiFly shield with Arduino, and everything works fine: I upload my skecth to Arduino via USB, I connect a 9V battery, I disconnect the USB, and the wifi module transmits everything fine (it transmits data to my web server).
When the battery runs out I replace with another battery, but then the wifi/arduino no longer communicates with my server..
I'm a newbie on Arduino and I don't understand whether if every time the power is off Arduino loses the program, or simply that the wifi is not able to auto-connect...
Is this a software problem or hardware?
And if software what am I doing wrong?
This is my sketch example - I'm just sending a string to my server:
#include "WiFly.h"
#include "Credentials.h" // includes ny user:pass wifi network
Client client("[***myserverip***]", 80);
void setup() {
Serial.begin(9600);
WiFly.begin();
if (!WiFly.join(ssid, passphrase)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}
connectServer();
}
void loop() {
if (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
delay(60000); // check every minute
connectServer();
}
}
void connectServer() {
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
String query = "GET /arduino/test?q=testString HTTP/1.0";
client.println(query);
client.println();
} else {
Serial.println("connection failed");
}
}
So everything works fine but when I unplug the power and plug it back the arduino doesnt restart the process.
I found the solution myself - the problem was with the hardware.
The problem was in my Arduino UNO R2, there is a known bug.
I bought a UNO R3 and I don't have this problem anymore.
Its because Arduino board doesn't have on board power on reset when using external power supply so you will always need to reset it just after supplying power. You can put a capacitor at reset pin to eliminate this issue. But if you are using USB as a power source then USB controller will reset the Arduino so in that case you will never have this problem.

Resources