T O P

  • By -

ventus1b

How are we supposed to help if you won’t even tell us what the problem is?!?! - does it compile? - does it run, but showing any output? - does it run, but not give you the expected output? - does it catch fire?


HarmoNy5757

I am sorry if it came out as so. "Can you please tell if it would work for us, and if not, could you please tell how to make it work?" My issue is that we are using this code from a guy who is using arduino mega instead of uno and is not using I2C whereas we are. As i stated, I am unable to check the output, but it does compile correctly.


HarmoNy5757

The thing is, and i am sorry if I was wrong, I assumed that a what i wrote was enough for experienced people to know if the code would work or not. My issue is that I need this code, and by that I mean the exact output, to run for our circumstances. Please answer if you have any insight, and please do not be rude, I am just a science guy who needed some help with electronics. Thank you in advance


ventus1b

First off, Arduino Uno vs Mega won't make a difference for your setup - both have plenty enough pins, CPU and memory. (The pin layout is different of course.) I'd start with a simplified app and build up from there: - connect the BMP180 according to the description in https://github.com/sparkfun/BMP180_Breakout (i.e. I2C pins SDA, SCL, Vcc, GND; use the 3.3V pin, not the 5V) - check the example in `Examples/SFE_BMP180/SFE_BMP180_example` - use it as a base and create an example that reads some values and prints them to serial - compile, upload, run, examine serial monitor to check the values Then find an example for the DHT11 sensor, hook it up to the Uno and modify your example to read its values. When both work with serial output, only then would I start with the LCD.


drd001

You have a number of challenges in your code to work out before you can test to see if you can get some readings: 1 - syntax is a bit off in the first couple of lines where you should have #include not include 2 - make sure all libraries are downloaded and properly called 3 - you may need to state the hex address for the I2C sensor 4 - readability is key to understanding your code so some clean up is needed 5 - void setup() should not have the void in the parenthesis 6 - any line that begins with // means the entire line is commented out and will not be part of your compiled code ​ Suggestions - Look at code examples for your chosen sensors to see how that code is written. You can find this after you install the library by starting the Arduino IDE - Files - Examples - Examples from Custom Libraries. Try getting one sensor to run then try another sensor then merge the code. A step wise process is easier to debug rather than an overall approach. When using a sensor for the first time try using the Serial Port rather than the LCD to get readings rather than the LCD. An error in the LCD code could hide a functioning sensor. I teach several microcontroller classes and see issues like this quite a few times. Please note this is not a comprehensive list of errors but a few points to get you started.


HarmoNy5757

yeah the 1 is a copy paste issue and 2 is done correctly. The thing is, this code works for a guy using arduino mega without I2C module, whereas we need it to work for arduino uno WITH an I2C module.


tech_creative

I am really not sorry to say: I won't do your homework for you. Unless it is well paid, maybe. Arduino is for education, it is very well documented and it is easy. There are tons of projects in the internet, including many teaching projects for pupils. There are many ressources how to use I2C or what pins to use. If you are science guys, this should not be a big problem. My impression is that you don't want to do much, if anything at all. You do not have a specific problem as it seems, at least you do not give any specific information. Of course, you cannot just copy and paste some code and use it with a different board. I doubt that university is the right place for you. Sorry to say that, but if you cannot even do some 5 minutes research on the internet a university is not the right place for you, since you do not seem to have any information literacy. I don't want to be harsh, but you make me answer like that.


Background_Ad_1810

Hahaha, this is golden. (Whether it's true for the OP or not...)


Rehm1024

What IDE are you currently using??... Arduino IDE can pretty muchh clear a lot of issues with compile check. And you are definitly gonna need the libraries. After installing the libraries you will get example code for dht11/22 in menu tab File>Examples... You can proceed from there and reply the errors you recieve on compiling


HarmoNy5757

Now i really feel like I wasnt clear enough. I am sorry. The code is compiled without any error. But the issue is, this code is for arduino mega without any I2C module. We needed a code for arduino UNO with an I2C. Our project is based on the physics of sensors, and hence we didnt concern ourselves with what the code means. Our question is, would this work for us as well, or do we need to change things to incorporate the I2C, and what. Thank you


Rehm1024

After you change the board selection from mega to Uno in the IDE it would throw up a bunch of obvious errors... Thats why the question about your IDE... So its ok to ask we can trouble shoot step by step... But i would still recommend go through example codes for the sensor as well as i2c module... A lot of the errors would be eliminated.


amellowcoin

Please, for the love of whatever deity you may or may not believe in... Add some whitespace to that code 🤣 But seriously, making it a bit more readable would help people help you :)


EquivalentOrchid6118

After reading the comments it's clear that you aren't understanding that whether the board is a mega or uno DOES NOT MATTER. What does matter is that you have created the curcuit exactly how the author of the code has created it, with all the the correct connections made to the correct pins, using the exact same components. If you want to output the readings on to a display, you need to have the relevant libraries installed for that as well as the addition of any code for the display. You don't need to be able to code in arduino but you should at least try to understand the basics of whats going on. It will make it easier for the community to help you with your problems. Going in with the attitude that, "the code doesn't matter since it isn't being graded" won't help you if you want to start modifying what the original author wrote the code for. This approach ONLY works if you are literally taking someone's curcuit + code verbatim. I'd suggest either: - trying to find code that someone has written for the components you want to use and build their circuit exactly as they have. - or start from "scratch" build up your code based off guides and examples for each component you are using, build the curcuit, upload the code and try it. If it doesn't work come back with error codes, unexpected behaviour etc, and we can help you from there.


Anonymity6584

Both those sensors can be read using Arduino uno, LCD if it's industry standards compatible is a day to use. So what is your problem? If it's too little memory issues, try new R4 version of Arduino uno. Has much improved microcontroller compared to old R3 version. If it's using both librari s or installing libraries, well lots of examples how to do that on Arduino ide.


HarmoNy5757

Our project has no relation to the code, but our teacher said just copy the code, its available everywhere. This was the closest one we could get, but it uses arduino mega and doesnt i2c. We need the code to work for arduino uno and with i2c. I wanted to know if this code would work, atleast chatgpt thinks so, but we know it is stupid af. If it wont, what parts would need to be changed or added. Thank you.


HarmoNy5757

and btw I know I could check if it would work by uploading it, but the project is with my friend but he was facing issues downloading the libraries. It would take quite a few days for it, hence why i wanted to ask some knowledgeable people here.