My gut feeling as far as the safe mode problems is that the safe mode firmware is probably not 1.0.5, as that doesn't update when you update the Oak board package on the Arduino IDE. Best way to rectify that problem at the moment is via a
serial update of the firmware, or by
doing a restore (but that takes longer and can be problematic). Hopefully there will be a way to force an OTA update/check of the safe mode firmware, but we're not there yet! Also, when you're in safe mode, you shouldn't need to reconfigure your wireless setup... you should see on the particle dashboard a few seconds after powering it up than the Oak is online, and in config mode, waiting for a new program. You can connect to the Oak with SoftAP if you want to change which network it connects to, but you don't need to if you're not changing that.
With the constant restarts,
what happens with nothing connected to the Oak? Will it let you program it then? (indicating there is something wrong with the wiring) ... that is a problem! I tried this on my Oak with nothing connected, and I get the same online cycles you've been getting... hm....
[13:26:05] Device change: Oak4
[13:26:13] Event: spark/status - online
[13:26:36] Event: spark/status - online
[13:26:46] Event: spark/status - offline
[13:26:47] Event: spark/status - online
[13:27:11] Event: spark/status - online
[13:27:34] Event: spark/status - onlineTo stop the crashes/restarts, it appears you need to not use analogRead!!! Which isn't a very good option
i.e. changing line 33 of the code you provided to not use anaalogRead stops the restarts... but defeats the purpose of the code as well! I also added a second delay (100) so I could see the led blinking.
/******************************************************************************
Piezo_Vibration_Sensor.ino
Example sketch for SparkFun's Piezo Vibration Sensor
(https://www.sparkfun.com/products/9197)
Jim Lindblom @ SparkFun Electronics
April 29, 2016
- Connect a 1Mohm resistor across the Piezo sensor's pins.
- Connect one leg of the Piezo to GND
- Connect the other leg of the piezo to A0
Vibrations on the Piezo sensor create voltags, which are sensed by the Arduino's
A0 pin. Check the serial monitor to view the voltage generated.
Development environment specifics:
Arduino 1.6.7
******************************************************************************/
const int PIEZO_PIN = A0; // Piezo output
const int PIEZO_LOWER_BOUND = 10; // Piezo values below this are ignored
const int BUZZER_PIN = 5;
const int LED_PIN = 1;
void setup()
{
//Serial.begin(9600);
pinMode(LED_PIN, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
}
void loop()
{
// Read Piezo ADC value in, and convert it to a voltage
int piezoADC = 100;//analogRead(PIEZO_PIN);
if(piezoADC > PIEZO_LOWER_BOUND) {
// Map the value to between 0 and 255 for PWM to the buzzer
//int toneVal = map(piezoADC, 0, 1023, 0, 255);
int toneVal = 100;
// Fire up the buzzer
analogWrite(BUZZER_PIN, toneVal);
digitalWrite(LED_PIN, HIGH);
delay(100);
analogWrite(BUZZER_PIN, 0);
digitalWrite(LED_PIN, LOW);
delay(100);
}
}I'm currently reading
a thread about AnalogRead on the ESP8266 causing resets, so I think it's a known bug that may or may not have been fixed...
I'm trying to work out how to use the following code as a workaround.
extern "C" {
#include "user_interface.h"
}
uint LDR_Value = 0; //Value of LDR (ADC)
LDR_Value=system_adc_read();