KenF:
You must be as dumb as me.
I'm going with "great minds think alike"....
KenF:
You must be as dumb as me.
I'm going with "great minds think alike"....
JimboZA
What sensors are they?
There is different kind of sensors that i wanna use them in a Fully UAV Project, working with other projects in the same time so my brain is a bit fried. Every day looking for components, code, taking decisions, spend money ![]()
Domino60:
Every day looking for components, code, taking decisions, spend money
The beauty of that job xD
Domino60:
JimboZAWhat sensors are they?There is different kind of sensors that i wanna use them in a Fully UAV Project, working with other projects in the same time so my brain is a bit fried. Every day looking for components, code, taking decisions, spend money
Well nobody can give specific code unless you say what they are. The wire library is generic, but as you'll see from the below code, sometimes device-specific lbraries are needed too.
This code accesses 2x I2C devices: it displays the time from an I2C RTC on an I2C oled screen.
/*********************************************************************
* adafruit mono oled screen
* ds1307 rtc
* this is really just a clock
*
* reminder: sda a4, scl a5
*********************************************************************/
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DS1307RTC.h>
#include <Time.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 32)
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void setup() {
//Serial.begin(9600);
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
// by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // initialize with the I2C addr 0x3C (for the 128x32)
// init done
// Show image buffer on the display hardware.
// Since the buffer is intialized with an Adafruit splashscreen
// internally, this will display the splashscreen.
display.display();
delay(250);
// Clear the buffer.
display.clearDisplay();
}
void loop() {
// text display
display.clearDisplay();
//display.setTextSize(1);
//display.setTextColor(WHITE);
display.setCursor(0,0);
display.setTextSize(2);
display.setTextColor(WHITE);
//get the time
tmElements_t tm;
if (RTC.read(tm)) {
print2digits(tm.Hour);
display.print(':');
print2digits(tm.Minute);
display.print(':');
print2digits(tm.Second);
}
display.display();
} //end of loop()
void print2digits(int number) { //ala jim
if (number >= 0 && number < 10) {
display.print('0');
}
display.print(number);
}
You won't get much more out of this thread unless you get specific....
Sorry for expletive, deleted by mod above. Heat of the moment....
(Most frustrating thread in my 3 years on the forum.)
Just figured your daughter being gone was finally getting to you ![]()
Ok i can tell that i will test the MPU6050 and BMP180.
What can you tell from that?
the MPU6050 got Gyro, Acc and Temp.
You need to print approx. 7 Values and the BMP180 use Baromiter and Temp of curse you can get Altm from it.
You see i have to print about 10 Values from both sensors.
What do you think about the code?
Domino60:
Ok i can tell that i will test the MPU6050 and BMP180.What do you think about the code?
Quick search found this and this for starters. I'm sure you could have found them.....
Quote from: Domino60 on Today at 02:54 pm
Every day looking for components, code, taking decisions, spend moneyThe beauty of that job xD
For me it's not a job yet, I'm keep doing projects to get more experience for the future,
I have crazy projects in my mind but low bugetright now im doing as many projects as possible
with my buget.I have a project in my mind that may cost 1mil$ and I'm not getting to spend money on every crap (component or material)
Domino60:
For me it's not a job yet, I'm keep doing projects to get more experience for the future,
I have crazy projects in my mind but low bugetright now im doing as many projects as possible
with my buget.I have a project in my mind that may cost 1mil$ and I'm not getting to spend money on every crap (component or material)
Job or hobby, I should have mentioned it. Anyway, if you're doing it to learn more, that's a great thing... But try to learn rather than asking for code.
Quality is better than quantity for learning and getting experience. And if you want to do as many as possible as fast as possible you won't learn much. So be patient, try to learn rather than getting things done for you as you seem to ask in this thread.
No ![]()
Quick search found this and this for starters. I'm sure you could have found them.....
I already got the code for that modules and already worked on them filtered ..etc
I mean about the I2C Bus, you just connect the 2 modules on the SDA, SCL and "just" copy/paste the
codes for the actual sensors?
I understand when you just got one value on the output of the sensor and print it but what about if the
sensor for 5 values (data) and the other sensor too. The I2C just automatically separate the output of the sensors or you need to do something in the code?
Job or hobby, I should have mentioned it. Anyway, if you're doing it to learn more, that's a great thing... But try to learn rather than asking for code.
Quality is better than quantity for learning and getting experience. And if you want to do as many as possible as fast as possible you won't learn much. So be patient, try to learn rather than getting things done for you as you seem to ask in this thread.
You see I'm always ask for example code not the actual ready (plug and play code) I need just an example
to understand with what I'm working with then i just modify it as I want (to do). Learning is good but doing mistakes with real electronic components may cost you more money. That's why i always start with an example.
Domino60:
The I2C just automatically separate the output of the sensors or you need to do something in the code?
YES!
I2C devices only put data on the bus when they are requested to do so. The request for data has to contain their individual address otherwise they ignore it.
The I2C just automatically separate the output of the sensors or you need to do something in the code?
You put the address of the device you want to talk to on the bus.
The other other devices on the bus ignore it, since it's no for them.
It really is that simple.
However, how you talk to the individual devices (which register addresses, and which bits within the registers) is device-specific, and for that you need to read the datasheet.
It's just like the AVR itself has an address bus; if you want to talk to the UART, the UART has a different address to the timers or the RAM.
In order to use I2C successfully , you need to understand the big picture. I2C is a PROTOCOL. It is based on a STANDARD (a reference document specifying both hardware and software). The hardware part is simple , and was already explained. I don't think anyone mentioned that I2C outputs are open collector so if the boards you are using don't have the pullup resistors built in , you would need to add them. Any off the shelf I2C breakout bd would have a 99% chance of having them built in. The standard value is 4.7 k ohm but can go as low as 2.2 k ohm if you have many devices on the bus. The thing you need to learn is the I2C communication protocol.
Thanks a lot, I'd like to be informed more and more but I don't have a lot of time for that.
That's unfortunate, because if you just use code you find on the net without understanding it then you will eventually have problems.
I suggest you read this:
I2C Instructable tutorial
So you just mean:
I got the code for the 1st sensor and i got the code for the 2nd sensor.
I just connect the both sensors in the SDA.SCL, resistors..etc and
I use the code from the sensors and put them together in the atmega and works?! I'm i right?
Domino60:
You see I'm always ask for example code not the actual ready (plug and play code) I need just an example
to understand with what I'm working with then i just modify it as I want (to do). Learning is good but doing mistakes with real electronic components may cost you more money. That's why i always start with an example.
You're right. You can afford making mistake with cheap components, at some point you'll burn something, that's just a question of time. But indeed, it would be bad if the mistake is done on something expensive.
Anyway, you won't burn anything with a wrong I2C code, don't worry.
My point was: try to read documentation a little more. For example, you're trying to set up an I2C bus, so you should learn basics about what is a bus and what is the I2C protocol.
It'll teach you how to hook up the whole thing. When you're done, try to draw a schematic by yourself and at the point, ask on the forum if the schematic is safe and good.
Then we'll talk about the code but before giving actual code I think we should discuss more about how to get information with I2C bus (the principle of master request and slave answer, IC2-controlled devices registers, and so on).
In my opinion this way of doing is more efficient, and will help you the next time you'll have to learn something totally new.
Domino60:
I already got the code for that modules and already worked on them filtered ..etc
Why the [expletive implied] didn't you say THAT 5 hours ago?
You'll need to examine code you have used for each before you copy and paste it all into one sketch. It's not impossible that they used the same variable names for example, and you'll need to check that. They might both for example have a temporary variable called "temp" and you might re-name them "temp1" and temp2".
Some where in both of those codes it will be assigning values to variables, like in my example above where there are time variables for hour and minutes: you must have variables for (say) X, Y and Z.... so just serial print X when you want X and Z when you want Z.
But tbh, if you're asking this kind of question- which really has NOTHING to do with I2C actually, once the library and your sketch has read the sensor into a variable- you might need to go back to some basics about variables and the use of serial print.
Anyway, you won't burn anything with a wrong I2C code, don't worry.
My point was: try to read documentation a little more. For example, you're trying to set up an I2C bus, so you should learn basics about what is a bus and what is the I2C protocol.
I'm not using just 2 sensors, there is several sensors that i have to connect on the ADC,SCL after that i need
to transmit the data to another circuit and do calculations...etc I'm not gonna enter in details.
You'll need to examine code you have used for each before you copy and paste it all into one sketch. It's not impossible that they used the same variable names for example, and you'll need to check that. They might both for example have a temporary variable called "temp" and you might re-name them "temp1" and temp2".
Meaning just copy/paste, is to actually copy/paste the codes for the sensors in an order without variable errors and other basic coding errors.
I'm not using just 2 sensors, there is several sensors that i have to connect on the ADC,SCL after that i need
to transmit the data to another circuit and do calculations...etc I'm not gonna enter in details.
As long as you don't break the bus capacitance specs, and you don't have two sensors with the same address, you've got no problems.
I have a simple project with I2C LCD, RTC, EEPROM and barometer/temperature sensor and everything is fine.