-->
Page 1 of 1

Sending sensor data via wifi to computer

PostPosted: Sun Apr 03, 2016 6:25 pm
by Hzd
Hi there.

First post, so be gentle :)

I've been way to brave, when I plunged into this so I'm asking for help.

Here's what I have:
Adafruit Huzzah Feather (esp8266)
Hr-sc04 range sensor
Arduino Uno

I have more or less no experience with arduino and programming and none with wifi languange.

Here's what I'm trying to acheive:
To send the distance measured by the range sensor to max/msp on my mac.

I managed to get the range info transmitted from the uno board over usb to the mac.

How do I proceed? Is it possible to program the huzzah to do all the work? I.e. do the range sensor and transmit the data or would I have to have the arduino to do the range stuff and transmit it to the huzzah, wich then transmits it to the computer?

I'm guessing I going to use some udp transmitting? Where can I find some code examples for that?


A bit of a mouthful og questions but this is all a bit of a mouthful for me :)

Re: Sending sensor data via wifi to computer

PostPosted: Mon Apr 04, 2016 2:45 am
by Hzd
I tried uplaoding this code to the esp8266, but I see no feedback in the serial monitor. It is the same code that works on the Arduino, thoug I've changed the trig and echo pins.

/*
HC-SR04 Ping distance sensor]

Echo to Arduino pin 13 Trig to Arduino pin 12
led 1 to Arduino pin 11
led2 to Arduino pin 10

*/

#define trigPin 5
#define echoPin 4
#define led 11
#define led2 10

void setup() {
Serial.begin (115200);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
}

void loop() {
long duration, distance;
digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000); - Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;


Serial.print("P ");
Serial.println(distance);




if (distance < 4) { // This is where the LED On/Off happens
digitalWrite(led,HIGH); // When the Red condition is met, the Green LED should turn off
digitalWrite(led2,LOW);
}
else {
digitalWrite(led,LOW);
digitalWrite(led2,HIGH);
}
if (distance >= 400 || distance <= 0){
Serial.println("Out of range");
}
else {

}
delay(100);
}

This is what I'm getting from the serial monitor:
ets Jan 8 2013,rst cause:4, boot mode:(3,1)

wdt reset
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld


Any thoughts?