Three possibilities to complete this week
Wired
Good explanation of this can be found in Jari Uusitalo's page from 2018.
For duplex communication, use software serial as the hardware UART that is available e.g. in Arduino Uno will not allow swapping modes of the pins assigned for serial communications.
The idea is to have one master (e.g. PC) and multiple slaves connected with two wire bus. See Neil's academy lecture. By default, all the slaves listen on both ports. Once data addressed to one of the slaves is received, that slave switches its other input port (connected to master Rx) to output mode and sends a response which is received by the master as well as all the other slaves. Once the transmission is over the pin is switched back to input (listening) mode.
If only simplex communication between master and slaves is required, there is no need for pin state switching. Example of this can be found e.g. in Yasir's page
Bluetooth
Connecting HM11 (HM10, HM9) to Arduino Uno and making led blink demo. Level shifting should be used in Bluetooth module Rx pin (5v => 3.3v) when Arduino board is used. Voltage divider is fine with moderate baud rates. You can run your own board with 3.3v in which case you do not need any extra components.
BLEScanner is a phone app that can be used to send data to Arduino Uno. The app can be found for Andrdoid and iOS devices.
Develop your own app using MIT App Inventor. Good BLE example.
ESP8266/ESP32
Level shifting should be used when operating with Arduino Uno board. You may have to power ESP with external power source
Tutorial for connecting ESP8266 with Arduino UNO and controlling with Blynk.
Another tutorial from Fab Academy 2018
Control Arduino led from a web page
Control ESP8266 with AT commands
Setting up Arduino IDE for ESP8266 or ESP32 if you want to use the GPIO pins of the ESPs.
Newer firmware uses 115.2kbps and older ones 9.6kbps
ESP-NOW for connecting ESP32s
EXAMPLE to be used with wireless BLE connection
#include BluetoothSerial.h
// Bluetooth Serial object
BluetoothSerial SerialBT;
// GPIO where LED is connected to
const int ledPin = 25;
// Handle received and sent messages
String message = "";
char incomingChar;
String temperatureString = "";
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
SerialBT.begin("ESP32");
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
// Read received messages (LED control command)
if (SerialBT.available()){
char incomingChar = SerialBT.read();
if (incomingChar != '\n'){
message += String(incomingChar);
}
else{
message = "";
}
Serial.write(incomingChar);
}
// Check received message and control output accordingly
if (message =="led_on"){
digitalWrite(ledPin, HIGH);
}
else if (message =="led_off"){
digitalWrite(ledPin, LOW);
}
delay(5);
}
UnoSoftwareSerial.ino SoftwareSerial.ino XiaoHost.inoXiaoRP2040Node.ino