Skip to content
Snippets Groups Projects
Commit 38ce8225 authored by Nathan Adams's avatar Nathan Adams
Browse files

wireless prototype build part one done

parent 8ad6cc0a
Branches
No related merge requests found
{
"sketch": "huzzah32/OSCIMU.ino",
"board": "esp8266:esp8266:huzzah",
"configuration": "xtal=80,vt=flash,exception=legacy,ssl=all,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200",
"port": "/dev/cu.SLAB_USBtoUART"
}
\ No newline at end of file
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/Users/lxinspc/Library/Arduino15/packages/esp8266/tools/**",
"/Users/lxinspc/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.2/**"
],
"forcedInclude": [],
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
],
"intelliSenseMode": "clang-x64",
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ Wireless IMU that sends OSC messages - based on the HUZZAH32 and Fusion 9DoF bre
### Hardware
https://www.adafruit.com/product/2472
......
// OSC IMU
// Nathan Adams / Atau Tanaka - Goldsmiths, University of London
// 2020
// OSCIMU.ino
// Main code for sensing orientation and sending an OSC message
// Code is based on OSC_propShield, which was designed to work on a Teensy 3.1, Teensy PropShield and Adafruit Airlift Wifi (which uses the ESP32 Wifi coprocessor)
// for this project we are using the Adafruit HUZZAH32 Feather board, with the Adafruit 9DoF Fusion Breakout based on the Bosch BNO055. So this code is
// slightly reworked to use the appropriate libaries (e.g. Wifi instead of the Adafruit WifiNINA port / Adafruits Sensor library)
// Build History
// Jan 2020 -> 1-prototype-build - get basics working across wifi
// ESP32 WiFi
#include <WiFi.h>
// Secrets file
#include "secrets.h"
// BNO055 / Adafruit Sensor library
#include <Adafruit_Sensor.h>
#include <Adafruit_BNO055.h>
#define BNO055_ADDRESS 0x28
//BNO055 is by standard for the fusion board on 0x28
Adafruit_BNO055 bno = Adafruit_BNO055(55, BNO055_ADDRESS);
// OSC Messaging
#include <OSCMessage.h> /// https://github.com/CNMAT/OSC
#include <OSCBundle.h> /// https://github.com/CNMAT/OSC
unsigned int localPort = 8888;
int sendCount;
const IPAddress outIp(SECRET_IP);
WiFiUDP udp;
#define SERIAL_SPEED 115200
#define VERSION 0.1
void setup() {
Serial.begin(SERIAL_SPEED);
while (!Serial) {
//wait for Serial to start up
}
//Try to connect to the Wifi netowrk provided in secrets
Serial.print("OSC IMU ");
Serial.println(VERSION);
Serial.println();
Serial.print("Connecting to ");
Serial.println(SECRET_SSID);
WiFi.begin(SECRET_SSID, SECRET_PASSWORD);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print('.');
}
Serial.println();
Serial.print("Success! Connected, IP Address is ");
Serial.println(WiFi.localIP());
Serial.println("\nStarting connection to server...");
// if you get a connection, report back via serial:
udp.begin(localPort);
//Now try to find the BNO055 sensor
if(bno.begin()) {
Serial.print("Found BNO055 on I2C address 0x");
Serial.println(BNO055_ADDRESS, HEX);
} else {
/* There was a problem detecting the BNO055 ... check your connections */
Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
while(1);
}
bno.setExtCrystalUse(true);
}
void loop() {
sensors_event_t event;
sendCount++;
if (sendCount > 1000) {
bno.getEvent(&event);
sendViaOSC(event.gyro.x, event.gyro.y, event.gyro.z);
sendCount = 0;
/* Display the floating point data */
/* Orientation */
Serial.print("oX: ");
Serial.print(event.orientation.x, 4);
Serial.print("\toY: ");
Serial.print(event.orientation.y, 4);
Serial.print("\toZ: ");
Serial.print(event.orientation.z, 4);
/* Acceleration */
Serial.print("\taX: ");
Serial.print(event.acceleration.x, 4);
Serial.print("\taY: ");
Serial.print(event.acceleration.y, 4);
Serial.print("\taZ: ");
Serial.print(event.acceleration.z, 4);
/* Gyro */
Serial.print("\tgX: ");
Serial.print(event.gyro.x, 4);
Serial.print("\tgY: ");
Serial.print(event.gyro.y, 4);
Serial.print("\tgZ: ");
Serial.print(event.gyro.z, 4);
/* New line for the next sample */
Serial.println("");
}
}
void sendViaOSC(float heading, float pitch, float roll) {
//orientation
OSCMessage msg("/gyro");
msg.add((int32_t)heading);
msg.add((int32_t)pitch);
msg.add((int32_t)roll);
//send out
udp.beginPacket(outIp, SECRET_OUTPORT);
msg.send(udp);
udp.endPacket();
msg.empty();
sendCount = 0;
}
// OSC IMU
// Nathan Adams / Atau Tanaka - Goldsmiths, University of London
// 2020
// secrets.h
//
// Copied from secrets.template.h and updated with specific local details
#define SECRET_SSID "circlewave"
#define SECRET_PASSWORD "SmallestWeirdNumber"
#define SECRET_IP 192, 168, 86, 20
#define SECRET_OUTPORT 9999
......@@ -10,5 +10,5 @@
#define SECRET_SSID "******"
#define SECRET_PASS "*******"
#define SECRET_IP 172, 20, 10, 8
#define SECRET_IP XXX, XXX, XXX, XXX
#define SECRET_OUTPORT 9999
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment