Page 1 of 1
Multiwii 2.4 as Slave
Posted: Mon Aug 01, 2016 9:47 am
by snow-man-01
Hello,
I want to set the Multiwii as Slave. I have another Arduino and I want to sent data from Arduino to Multiwii. Does anybody know where in the Code Multiwii 2.4 I can set the following code for the slave:
#include <Wire.h>
void setup() {
Wire.begin(8); // join i2c bus with address #8
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}
void loop() {
delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany) {
while (1 < Wire.available()) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}
Re: Multiwii 2.4 as Slave
Posted: Mon Aug 01, 2016 11:18 am
by gregd72002
Multiwii uses its own I2C implementation and is not using Wire.h. Combining 2 different i2c approaches is not a good idea and most likely will never work.
Re: Multiwii 2.4 as Slave
Posted: Mon Aug 01, 2016 12:44 pm
by snow-man-01
Mh,.. Do you have any idea to solve this problem?
Re: Multiwii 2.4 as Slave
Posted: Mon Aug 01, 2016 1:42 pm
by gregd72002
it depends on what you are trying to do. Do you have to use i2c, why not to use serial? What data will you be sending, how much of it....
Re: Multiwii 2.4 as Slave
Posted: Wed Aug 03, 2016 2:48 pm
by snow-man-01
Yes, I use i2c. what do you mean with serial? ftdi interface?
I want to send int values from an arduino to multiwii. this arduino is connected with 8 ultrasonic sensor. So the arduino sends values from the sensor to the multiwii. There are 100 values sent per second.
The post ist already working when the multiwii controller does not have the code for the quadcopter.
Re: Multiwii 2.4 as Slave
Posted: Wed Aug 03, 2016 4:13 pm
by gregd72002
for arduino to arduino communication over i2c you might want to take a look at I2C_GPS_NAV for and example
I2C_GPS_NAV is an arduino based software that interfaces with Multiwii on one end and GPS on the other:
MultiWii <-------[i2c]------> I2C_GPS_NAV <---------- [serial] ---------> GPS
Re: Multiwii 2.4 as Slave
Posted: Wed Aug 03, 2016 7:22 pm
by snow-man-01
I do not want to use the GPS. Or must I only use the I2C_GPS_NAV without using GPS to connent the arduino to multiwii?
Re: Multiwii 2.4 as Slave
Posted: Thu Aug 04, 2016 8:56 am
by gregd72002
I2C_GPS_NAV is just an example. You will need to code something yourself.
Re: Multiwii 2.4 as Slave
Posted: Wed Aug 10, 2016 1:27 pm
by snow-man-01
can you send me more information (a link) please where I can connect the arduino pro mini to Multiwii? I do not know how I can do that.
Re: Multiwii 2.4 as Slave
Posted: Sat Aug 13, 2016 2:26 pm
by Hamburger
Use the msp protocol over serial
Re: Multiwii 2.4 as Slave
Posted: Mon Aug 15, 2016 9:25 am
by snow-man-01
what must I change in the protocoll.cpp? I see two important function: void serialCom and void evaluateCommand.
Re: Multiwii 2.4 as Slave
Posted: Mon Aug 15, 2016 10:21 am
by snow-man-01
I added this under the function evaluateCommand:
case MSP_Data_promini
mspAck();
s_struct_w((uint8_t*),);
break;
But do not know what I must add into.
Posted: Wed Aug 17, 2016 4:15 am
by Zviki
I think that sonar could work through digital input pin... Next time try Google. [URL]Arduino Sonar - Arduino Project Hub
https://create.arduino.cc/projecthub/fa ... dar-69b8fe[/URL]
Sent from my SM-N910C using Tapatalk
Multiwii 2.4 as Slave
Posted: Wed Aug 17, 2016 4:26 am
by Zviki
Re: Multiwii 2.4 as Slave
Posted: Wed Aug 17, 2016 9:22 am
by snow-man-01
Yes, but I want to connect 8 Ultrasonic sensors. There are not enough digital ports.
Multiwii 2.4 as Slave
Posted: Fri Aug 19, 2016 5:19 am
by Zviki
snow-man-01 wrote:Yes, but I want to connect 8 Ultrasonic sensors. There are not enough digital ports.
You can connect them through I2C. All on the same port. You just need to assign different address for each one. Also, on second link I posted is explained how to connect Arduino to Arduino.
Sent from my SM-N910C using Tapatalk
Posted: Fri Aug 19, 2016 5:25 am
by Zviki
Here is explained how to and also code is there How to connect more than 10 sensors to Arduino uno r3 - Arduino Stack Exchange
http://arduino.stackexchange.com/questi ... ino-uno-r3Sent from my SM-N910C using Tapatalk
Posted: Fri Aug 19, 2016 5:32 am
by Zviki
Or here Raspberry Pi • View topic - Using an I2C expander to connect multiple distance sensors?
https://www.raspberrypi.org/forums/view ... 2&p=934447Sent from my SM-N910C using Tapatalk