If BlueTooth or Wifi connected?

I can't figure out how to write a code that would make BlueTooth work when it's connected and if it's not connected, wifi is running ?

I understand that they can not work at the same time, but I want that either bluetooth worked if the client had time to connect to it, if at the end of the timeout there are no connections, then then run the connection on WiFi

I hope it's clear.

Thansk a lot

More details please

Which Arduino, for a start

I use ESP32, and exmaple below, but this only simple Bluetooth connected without WiFi can't figure where to finish the WiFi connection code for what would work either Bluetooth or Wifi:

> Blockquote
  Rui Santos
  Complete project details at https://randomnerdtutorials.com

// Load libraries
#include "BluetoothSerial.h"
#include <OneWire.h>
#include <DallasTemperature.h>

// Check if Bluetooth configs are enabled
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it

// Bluetooth Serial object
BluetoothSerial SerialBT;

// GPIO where the DS18B20 is connected to
const int oneWireBus = 15;          
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(oneWireBus);
// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);

// Handle received and sent messages
String message = "";
char incomingChar;
String temperatureString = "";

// Timer: auxiliar variables
unsigned long previousMillis = 0;    // Stores last time temperature was published
const long interval = 1000;         // interval at which to publish sensor readings

void setup() {
  // Bluetooth device name
  Serial.println("The device started, now you can pair it with bluetooth!");

void loop() {
  unsigned long currentMillis = millis();
  // Send temperature readings
  if (currentMillis - previousMillis >= interval){
    previousMillis = currentMillis;
    temperatureString = String (sensors.getTempCByIndex(0));

> Blockquote

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.