Jump to content

Hello,

 

I really need some help, and I'm hoping someone here can help me. 

I have a problem to solve, I just started a project on the arduino. I have a sensor that is going to send data to my web server with a cc3000 wifi sheild. But my problem is i suck at writing C/C++ code. So basiclly i need help to write a code that can read my sensor data (a DHT11 Sensor, for starts) and then send it over the LAN to my web server wich runs apache with a mysql database. And the database is going to pick up the data and store it. Im not sure if i should get the data by Push or Pull from the server side, but I hope someone here can help me with all this.

 

And also if you do a example code of similair please try to comment alot if possible, easier to learn and modify then.

 

All help is greatly apreciated :D 

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/
Share on other sites

Link to post
Share on other sites

And right now i actully got a Arest code that is kind of working, it can send the data in json format but im not able to display it on my server now..

I can only see it if i make a call for the data in the browser but it wont work with my web code

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4311751
Share on other sites

Link to post
Share on other sites

You can install a library to your Arduino IDE, that will help connecting directly to the database and storing the data that you want.

 

Take a look at MySQL Arduino project: http://bazaar.launchpad.net/~chuck-bell/mysql-arduino/release-1.0.2-beta/view/head:/Readme.txt

 

You can check for examples in the author's blog: http://drcharlesbell.blogspot.com.br/2013/04/introducing-mysql-connectorarduino_6.html

Well I'm using the cc3000 wifi sheild and not the Ethernet one, soo will it work if i modify the code somehow? And as i said im terrible at coding C/C++ code so I probably need more help with the code is that is possible.

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4312963
Share on other sites

Link to post
Share on other sites

I cant get it to work beacuse the mysql.h includes the Ethernet instead of the cc3000, and i got the adafruit cc3000, but that maybe isnt a problem?

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4313448
Share on other sites

Link to post
Share on other sites

Is it possible for you to edit the files, beacuse it seems like im donig something wrong, I'm just getting more errors when i change them.

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4313898
Share on other sites

Link to post
Share on other sites

Okey now the libraries seems to work, but it says its errors in the code of the test_program.ino that i dont really know how to fix..kind of noobie at C

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4314003
Share on other sites

Link to post
Share on other sites

It says this when compiling: test_program.ino:10:1: error: expected ',' or ';' before 'unsigned'

test_program.ino: In function 'void loop()':
test_program.ino:55:29: error: 'server_addr' was not declared in this scope
test_program.ino:62:3: error: 'else' without a previous 'if'
Error compiling.

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4314084
Share on other sites

Link to post
Share on other sites

Well the code seems to work now, but i could use some help with setting up the database right too, haven't really succeded to make a connection but im getting closer atleast

 

I only get to this stage:

 

Initialising the CC3000 ...
Connected!
Request DHCP
Connecting...
 
Then it stops there

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4320468
Share on other sites

Link to post
Share on other sites

Yeah, i probably need help to create the database isnt the good on it, and the DB user and password is my login for phpmyadmin right?

 

[EDIT]

It gets stuck on Connecting to DB again, so im thinking ive done something wrong with the databases and all that since im quite new to databases too..

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4320981
Share on other sites

Link to post
Share on other sites

Okey thanks, but I'm still having the problem that it wont connect to the DB...

 

[EDIT]

 

What should the database name be? And what should the Table name be and what properties should it have and how many columns?

 

Just to check so ive made it all right or not

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4321246
Share on other sites

Link to post
Share on other sites

I'm not getting anything in the serial monitor now, should it be so? And like the databases is still confusing do you know an good tutorial?, and what in the program points at the name of the database and the table?

 

Is it like this? Or am i totally lost?

 

test_arduino.dht

 

test_arduino=database

dht=table

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4329219
Share on other sites

Link to post
Share on other sites

Okey, first its a problem when enabling the debug, i tried to find it but didn't succed. 

 

Here is the output:

test_program.ino: In function 'void setup()':

test_program.ino:73:32: error: expected ')' before ';' token
Error compiling.
 
[EDIT]
Found the missing ')' and solved it.
 
And I need help with the database stuff, I'm lost. I have an screenshot here so you can see. What am i supposed to type in all these columns and stuff? If you got time and its not to hard could you explain pretty deep? Sorry for being pretty bad at this stuff..
 
0jEdvVT.png
 
I know the resulution is a bit weird but manage to capture both screens. But maybe it help to trubleshoot with a picture.

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4330093
Share on other sites

Link to post
Share on other sites

Okey, it wont connect to the database I can't figure out why. I've tried different users but still don't work. It stops at this in the serial monitor:

 

Initialising CC3000

Connected!
Request DHCP
DHCP acquired
Connecting to DB
 
(Been sitting in this stage for 10-15 min)
 
But the database seems to work great though I can add the data manually to it without any problems at all, so thats good atleast.
 
But do you have any ideas why it wont connect?

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4336011
Share on other sites

Link to post
Share on other sites

Can't get it to work, is it a probelm if the server it will connect to is on an raspberry pi? It stops at Connecting to DB. I have set an static ip on the raspberry so that should not be a problem and the ip is right in the program. Can't figure out why it won't connect.

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4344081
Share on other sites

Link to post
Share on other sites

Okey, il try to do some debugging. It would probably be in the section(s) of code with the connections to the server right?

FX-8350 GTX760 16GB RAM 250GB SSD + 1TB HDD

 

"How many roads must a man walk down?" "42"

Link to comment
https://linustechtips.com/topic/317237-arduino-code-help/#findComment-4353951
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×