Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "arduino_secrets.h"
- // DallasTemperature(Edison) for i686 - Version: Latest
- #include <DallasTemperature.h>
- #include "BluetoothSerial.h" //código añadido
- #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED) //código añadido
- #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it //código añadido
- #endif //código añadido
- #if !defined(CONFIG_BT_SPP_ENABLED)//código añadido
- #error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip.//código añadido
- #endif//código añadido
- BluetoothSerial SerialBT;//código añadido
- // OneWire(Edison) for i686 - Version: Latest
- #include <OneWire.h>
- #define ONE_WIRE_BUS 15 // Data wire is connected to ESP32 GPIO15
- OneWire oneWire(ONE_WIRE_BUS);//Setup a oneWire instance to communicate with a OneWire device
- DallasTemperature sensors(&oneWire);//Pass our oneWire reference to Dallas Temperature sensor
- //device addresses
- DeviceAddress sensor1 = { 0x28, 0x51, 0x3A, 0x76, 0xE0, 0x01, 0x3C, 0x81 };
- DeviceAddress sensor2 = { 0x28, 0x8F, 0x43, 0x76, 0xE0, 0x01, 0x3C, 0xC8 };
- /*
- Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
- https://create.arduino.cc/cloud/things/7c8b6ecb-45ee-446e-9b50-b832d5a15992
- Arduino IoT Cloud Variables description
- The following variables are automatically generated and updated when changes are made to the Thing
- float temp_1;
- float temp_2;
- Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
- which are called when their values are changed from the Dashboard.
- These functions are generated with the Thing and added at the end of this sketch.
- */
- #include "thingProperties.h"
- #include "arduino_secrets.h"
- // DallasTemperature(Edison) for i686 - Version: Latest
- #include <DallasTemperature.h>
- #include "BluetoothSerial.h"
- #if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
- #error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
- #endif
- #if !defined(CONFIG_BT_SPP_ENABLED)
- #error Serial Bluetooth not available or not enabled. It is only available for the ESP32 chip.
- #endif
- BluetoothSerial SerialBT;
- // OneWire(Edison) for i686 - Version: Latest
- #include <OneWire.h>
- #define ONE_WIRE_BUS 15 // Data wire is connected to ESP32 GPIO15
- OneWire oneWire(ONE_WIRE_BUS);//Setup a oneWire instance to communicate with a OneWire device
- DallasTemperature sensors(&oneWire);//Pass our oneWire reference to Dallas Temperature sensor
- //device addresses
- DeviceAddress sensor1 = { 0x28, 0x51, 0x3A, 0x76, 0xE0, 0x01, 0x3C, 0x81 };
- DeviceAddress sensor2 = { 0x28, 0x8F, 0x43, 0x76, 0xE0, 0x01, 0x3C, 0xC8 };
- /*
- Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
- https://create.arduino.cc/cloud/things/7c8b6ecb-45ee-446e-9b50-b832d5a15992
- Arduino IoT Cloud Variables description
- The following variables are automatically generated and updated when changes are made to the Thing
- float temp_1;
- float temp_2;
- Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
- which are called when their values are changed from the Dashboard.
- These functions are generated with the Thing and added at the end of this sketch.
- */
- #include "thingProperties.h"
- void setup() {
- // Initialize serial and wait for port to open:
- Serial.begin(115200);
- // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
- delay(1500);
- SerialBT.begin("ESP32");
- sensors.begin();
- // Defined in thingProperties.h
- initProperties();
- // Connect to Arduino IoT Cloud
- ArduinoCloud.begin(ArduinoIoTPreferredConnection);
- /*
- The following function allows you to obtain more information
- related to the state of network and IoT Cloud connection and errors
- the higher number the more granular information you’ll get.
- The default is 0 (only errors).
- Maximum is 4
- */
- setDebugMessageLevel(2);
- ArduinoCloud.printDebugInfo();
- }
- void loop() {
- ArduinoCloud.update();
- // Your code here
- if (Serial.available()) {
- SerialBT.write(Serial.read());
- }
- if (SerialBT.available()) {
- Serial.write(SerialBT.read());
- }
- temp_1 = sensors.getTempC(sensor1);
- temp_2 = sensors.getTempC(sensor2);
- Serial.print(F("Requesting temperatures..."));
- sensors.requestTemperatures(); // Send the command to get temperatures
- Serial.println(F("DONE"));
- Serial.print(F("Sensor 1(*C): "));
- Serial.print(sensors.getTempC(sensor1));
- Serial.print(F(" Sensor 1(*F): "));
- Serial.println(sensors.getTempF(sensor1));
- SerialBT.print(F("*T"));
- SerialBT.print(sensors.getTempC(sensor1));
- SerialBT.print(F("*"));
- SerialBT.print(F("*S"));
- SerialBT.print(sensors.getTempC(sensor2));
- SerialBT.print(F("*"));
- Serial.println(sensors.getTempF(sensor1));
- Serial.print(F("Sensor 2(*C): "));
- Serial.print(sensors.getTempC(sensor2));
- Serial.print(F(" Sensor 2(*F): "));
- Serial.println(sensors.getTempF(sensor2));
- delay(2000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement