Multiwii 2.4 as Slave
-
- Posts: 18
- Joined: Mon Jul 18, 2016 9:50 am
Multiwii 2.4 as Slave
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
}
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
}
-
- Posts: 103
- Joined: Fri Dec 12, 2014 5:16 pm
Re: Multiwii 2.4 as Slave
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.
-
- Posts: 18
- Joined: Mon Jul 18, 2016 9:50 am
Re: Multiwii 2.4 as Slave
Mh,.. Do you have any idea to solve this problem?
-
- Posts: 103
- Joined: Fri Dec 12, 2014 5:16 pm
Re: Multiwii 2.4 as Slave
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....
-
- Posts: 18
- Joined: Mon Jul 18, 2016 9:50 am
Re: Multiwii 2.4 as Slave
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.
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.
-
- Posts: 103
- Joined: Fri Dec 12, 2014 5:16 pm
Re: Multiwii 2.4 as Slave
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
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
-
- Posts: 18
- Joined: Mon Jul 18, 2016 9:50 am
Re: Multiwii 2.4 as Slave
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?
-
- Posts: 103
- Joined: Fri Dec 12, 2014 5:16 pm
Re: Multiwii 2.4 as Slave
I2C_GPS_NAV is just an example. You will need to code something yourself.
-
- Posts: 18
- Joined: Mon Jul 18, 2016 9:50 am
Re: Multiwii 2.4 as Slave
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
Use the msp protocol over serial
-
- Posts: 18
- Joined: Mon Jul 18, 2016 9:50 am
Re: Multiwii 2.4 as Slave
what must I change in the protocoll.cpp? I see two important function: void serialCom and void evaluateCommand.
-
- Posts: 18
- Joined: Mon Jul 18, 2016 9:50 am
Re: Multiwii 2.4 as Slave
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.
case MSP_Data_promini
mspAck();
s_struct_w((uint8_t*),);
break;
But do not know what I must add into.
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
https://create.arduino.cc/projecthub/fa ... dar-69b8fe[/URL]
Sent from my SM-N910C using Tapatalk
Multiwii 2.4 as Slave
Also https://www.google.si/search?site=&source=hp&ei=_9izV9StI4n-Upnyo9gJ&q=How+to+connect+one+arduino+to+another+&oq=How+to+connect+one+arduino+to+another+&gs_l=mobile-gws-hp.3...6223.19916.0.21532.33.29.4.9.9.0.269.4629.0j20j8.28.0....0...1c.1j4.64.mobile-gws-hp..1.31.3381.3..0j5j35i39k1j0i10k1j0i20k1j0i22i30k1.t93UEBh3KXI
Sent from my SM-N910C using Tapatalk
Sent from my SM-N910C using Tapatalk
-
- Posts: 18
- Joined: Mon Jul 18, 2016 9:50 am
Re: Multiwii 2.4 as Slave
Yes, but I want to connect 8 Ultrasonic sensors. There are not enough digital ports.
Multiwii 2.4 as Slave
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
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-r3
Sent from my SM-N910C using Tapatalk
http://arduino.stackexchange.com/questi ... ino-uno-r3
Sent from my SM-N910C using Tapatalk
Or here Raspberry Pi • View topic - Using an I2C expander to connect multiple distance sensors?
https://www.raspberrypi.org/forums/view ... 2&p=934447
Sent from my SM-N910C using Tapatalk
https://www.raspberrypi.org/forums/view ... 2&p=934447
Sent from my SM-N910C using Tapatalk