Not able to get Qwiic relay to turn on or off using an app developed in MIT App Inventor.
Can get the Example Qwiic relay on/off to run, no problem
The app currently turns on/off the built in LED or the RGB LED, no problem
Trying to substitute the relay.turnRelayOn(); to work instead of digitalWrite(led_pin_13, value); in a Switch/Case/Break as shown but having no success.
#define RGB_BRIGHTNESS 128 // Change white brightness (max 255)
#include "BluetoothSerial.h" // this header is needed for Bluetooth Serial -> works ONLY on ESP32
#include <Wire.h>
#include "SparkFun_Qwiic_Relay.h"
#define RELAY_ADDR 0x18 // Alternate address 0x19
Qwiic_Relay relay(RELAY_ADDR);
BluetoothSerial ESP_BT; // init Class:
// init PINs: assign any pin on ESP32
int led_pin_1 = 4;
int led_pin_2 = 12;
int led_pin_13 = 13; // On some ESP32 pin 2 is an internal LED, mine did not have one
int incoming;// Parameters for Bluetooth interface
void setup() {
Wire.begin();
Serial.begin(115200);
ESP_BT.begin("ESP32_Control"); //Name of your Bluetooth interface -> will show up on your phone
pinMode (led_pin_1, OUTPUT);
pinMode (led_pin_2, OUTPUT);
pinMode (led_pin_13, OUTPUT);
}
void loop() {
// -------------------- Receive Bluetooth signal ----------------------
if (ESP_BT.available())
{
incoming = ESP_BT.read(); //Read what we receive
// separate button ID from button value -> button ID is 10, 20, 30, etc, value is 1 or 0
int button = floor(incoming / 10);
int value = incoming % 10;
#ifdef RGB_BUILTIN
switch (button) {
case 1: // use this case to indicate Bluetooth connected on RGB Led
Serial.println("Bluetooth connected:"); //Serial.println(value);
for (int i = 0; i<3; i++){
neopixelWrite(RGB_BUILTIN,0,(value*RGB_BRIGHTNESS),0); // Green
delay(500);
neopixelWrite(RGB_BUILTIN,(value*RGB_BRIGHTNESS),0 ,0); // Red
delay(500);
neopixelWrite(RGB_BUILTIN,0,0,(value*RGB_BRIGHTNESS)); // Blue
delay(500);
neopixelWrite(RGB_BUILTIN,0,0,0); // off
delay(500);
}
digitalWrite(led_pin_1, 0);
// digitalWrite(led_pin_1, value);
break;
case 2: // use this case to turn beep on for half second
Serial.print("Beep:"); Serial.println(value);
neopixelWrite(RGB_BUILTIN,0,(value*RGB_BRIGHTNESS),0); // Green
delay(500);
neopixelWrite(RGB_BUILTIN,0,0,0); // Off
// digitalWrite(RGB_BUILTIN, LOW); // Turn the RGB LED off
// digitalWrite(led_pin_2, value);
// digitalWrite(RGB_BUILTIN, value); // Turn the RGB LED white
// digitalWrite(led_pin_2, 0);
break;
case 3: //use this case to turn on horn
Serial.println("Horn:"); //Serial.println(value);
relay.turnRelayOn(); // Let's turn on the relay...
//digitalWrite(led_pin_13, value);
break;
#endif
}
}
}
Getting an error and no relay function, as shown below. Any suggestions would be appreciated.
Bluetooth connected:
22:25:47.791 → Horn:
22:25:47.791 → Guru Meditation Error: Core 1 panic’ed (LoadProhibited). Exception was unhandled.
22:25:47.791 →
22:25:47.791 → Core 1 register dump:
22:25:47.791 → PC : 0x400d3777 PS : 0x00060830 A0 : 0x800d38bb A1 : 0x3ffc8bd0
22:25:47.791 → A2 : 0x00000000 A3 : 0x00000018 A4 : 0x00000002 A5 : 0xffffffff
22:25:47.826 → A6 : 0x3ffbbcc0 A7 : 0x00000000 A8 : 0x800d521e A9 : 0x3ffc8b90
22:25:47.826 → A10 : 0x00000001 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x00000000
22:25:47.826 → A14 : 0x3ffbbcc0 A15 : 0x00000000 SAR : 0x0000001c EXCCAUSE: 0x0000001c
22:25:47.826 → EXCVADDR: 0x00000040 LBEG : 0x40090fb1 LEND : 0x40090fc1 LCOUNT : 0xffffffff
22:25:47.826 →
22:25:47.826 →
22:25:47.826 → Backtrace:0x400d3774:0x3ffc8bd00x400d38b8:0x3ffc8bf0 0x400d390c:0x3ffc8c10 0x400d3959:0x3ffc8c30 0x400d399d:0x3ffc8c50 0x400d2020:0x3ffc8c70 0x400d4d3d:0x3ffc8c90
22:25:47.872 →
22:25:47.872 →
22:25:47.872 →
22:25:47.872 →
22:25:47.872 → ELF file SHA256: 0000000000000000
22:25:47.872 →
22:25:47.872 → Rebooting…
22:25:47.872 → ets Jul 29 2019 12:21:46
22:25:47.872 →
22:25:47.872 → rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
22:25:47.872 → configsip: 0, SPIWP:0xee
22:25:47.872 → clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
22:25:47.872 → mode:DIO, clock div:1
22:25:47.872 → load:0x3fff0030,len:1184
22:25:47.872 → load:0x40078000,len:13160
22:25:47.872 → load:0x40080400,len:3036
22:25:47.872 → entry 0x400805e4