Pulse counter that writes to MySQL Database

photon
Tags: #<Tag:0x00007f03957b7628>

#1

Good Morning,

A couple months ago I started trying to make a water meter connect with the cloud using a photon to count pulses. I received a lot of help from the community, especially from @Rftop he helped me going as far as to re-write my base code and included a ton of comments that helped me learn my way around it , and even going through my meter datasheet and troubleshooting the connections/settings to use.

Since then I have worked on it further and now have a pulse counter that triggers a particle webhook that sends information to a website to be stored into a MySQL database. I wanted to share in case it helps anyone searching the forums in the future, and to give you guys an opportunity to provide any feedback or point out any issues you can see.

I am a beginner and this is my first foray into it since learning HTML about 10 years ago haha so any advice is a big help.


Cant get photon code,webhook,php to log data to mysql
#2

Not a comment on the actual code, but neither the C++ syntax nor the PHP syntax is highlighted in the github repo files. Perhaps you could add file extensions onto the file names so that github properly identifies the code and can apply the syntax color coding. I did a quick google search for how to force that syntax highlighting but I didn’t find anything good. I think a file extension should do it though.


#3

Thank you ! I will change that

Edit: just changed the extensions, looked like that did correct it


#4

You changed your IDEcode file to be a .h but that is a rather counterintuitive (to say the least) extension. .h should be reserved for header files that (mostly) don’t contain active code.
You’d rather want to call it .cpp (although even IDEcode doesn’t really give away what it does ;-)).
So maybe something like PulseCount.cpp would be better fitting.

For coding style you may also want to adopt a consistent, meaningful indentation scheme for C code as well as reducing blank lines. It often helps more to be able to see more of the active code correctly aligned in one screen page than breaking it up at arbitrarily places.


#5

Thank you!

Edit: Changed the file name as you suggested and removed blank lines. I will take some time to read documentation on coding style to make it more cohesive going forward