I have been working on a telemetry system using a Nano, a 10DOF module, and Arduino IDE on Windows 7.
Everything was working well until I moved the Nano and 10DOF module. I don't know if I zapped the 10DOF or the Nano - humidity in here is low and maybe there was static electricity.
After the move, Windows 7 is identifying the Nano as "USB-SERIAL CH340" on COM6. I tried uninstalling the device and rebooting the computer but the Nano still comes back as "USB-SERIAL CH340"
When I upload the following program, it appears to load and executes to the "Initialize sensors" statement in the setup loop. It does not print any error messages to the serial port and appears to freeze at that point.
Did I zap my Nano? Did I zap the sensor board?
If the program uploads, I don't understand why Windows has misidentified the Nano board and why nothing prints after the sensor initialization???
HELP?
/*
Telemetry Transmit with 10DOF Sensors
*/
#include <SoftwareSerial.h>
// software serial #1: RX = digital pin 10 (not used), TX = digital pin 9
SoftwareSerial portOne(10, 9);
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM303_U.h>
#include <Adafruit_BMP085_U.h>
#include <Adafruit_L3GD20_U.h>
#include <Adafruit_10DOF.h>
// Assign a unique ID to the sensors
Adafruit_10DOF dof = Adafruit_10DOF();
Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301);
Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(30302);
Adafruit_BMP085_Unified bmp = Adafruit_BMP085_Unified(10085);
//Define soft variables
int compass = 0 ; // Compass in degrees, default 0 degrees
int pressure = 600 ; // Pressure in Pascals,
int pitch = 0 ; // pitch in degrees
int checksum = 0 ;
// Timing
int tick = 0 ; // 1 Second clock
unsigned long currentT = 0 ;
unsigned long lastT = 0 ;
struct DOFDATA
{
uint16_t compass;
uint16_t pressure;
uint16_t pitch;
uint16_t checksum ;
};
float heading ;
//************** SETUP ***********************
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.begin(9600);
// Initialise the sensors
Serial.println("initialize sensors"); Serial.println("");
if(!accel.begin())
{
// There was a problem detecting the LSM303 ... check your connections
Serial.println(F("Ooops, no LSM303 detected ... Check your wiring!"));
while(1);
}
if(!mag.begin())
{
// There was a problem detecting the LSM303 ... check your connections
Serial.println("Ooops, no LSM303 detected ... Check your wiring!");
while(1);
}
if(!bmp.begin())
{
// There was a problem detecting the BMP180 ... check your connections
Serial.println("Ooops, no BMP180 detected ... Check your wiring!");
while(1);
}
Serial.println("Tx Started here"); Serial.println("");
// Start software serial port
portOne.begin(600);
}
//************** LOOP ***********************
void loop() {
// 1 Second timer loop
(currentT = (millis()/1000)) ;
if (currentT > lastT) {
(lastT = currentT ) ;
tick++ ;
Serial.print ("Tick ") ; Serial.println (tick) ;
}
if (tick >= 6) {
(tick = 0) ;
}
switch(tick){
case 3: {
// upData () ; // update data
sensorRead() ; // read sensors
tick++ ;
break ;
}
case 5: {
sendData () ; //transmit data
tick++ ;
break ;
}
}
}
// *********************** Sensor Reads *****************
void sensorRead(){
sensors_event_t accel_event;
sensors_event_t mag_event;
sensors_event_t bmp_event;
sensors_vec_t orientation;
// Calculate pitch and roll from the raw accelerometer data
accel.getEvent(&accel_event);
if (dof.accelGetOrientation(&accel_event, &orientation))
{
// 'orientation' should have valid .roll and .pitch fields
(pitch =(orientation.pitch));
// Get a new sensor event
sensors_event_t event;
bmp.getEvent(&event);
// Display the results (barometric pressure is measure in hPa)
if (event.pressure)
{
// Display atmospheric pressure in hPa
(pressure = (event.pressure));
}
else
{
Serial.println("Sensor error");
}
}
// Calculate the heading using the magnetometer
mag.getEvent(&mag_event);
if (dof.magGetOrientation(SENSOR_AXIS_Z, &mag_event, &orientation))
{
// 'orientation' should have valid .heading data now
(compass = (orientation.heading));
}
return ;
}
// ******************* DATA SEND ****************
void sendData (){
checksum = ((compass)+(pressure)+(pitch));
// data to send
DOFDATA dd;
dd.compass = compass ; // 0 to 359 degrees, 0 to 168$
dd.pressure = pressure ; // to 1200 "H2O, 0 to 4B0$
dd.pitch = pitch ; // -20 to +20 Degrees, ffec to 14$
dd.checksum = checksum ;
int numBytes = portOne.write((byte*)&dd, sizeof(dd));
Serial.print ("Heading ") ;
Serial.println (compass) ;
Serial.print ("Pressure ") ;
Serial.println (pressure) ;
Serial.print ("Pitch ") ;
Serial.println (pitch) ;
Serial.print ("Checksum ") ;
Serial.println (checksum) ;
Serial.println (" ") ;
return ;
}