Need Help troubleshooting

Hi I’m currently trying to merge two existing codes i found online so that i can excess the data collected from sensor to a web server. I am currently using an Arduino Ethernet Shield which is connected to a router. The code i’m currently trying to merge is the one from this website (Scroll down to “Displaying sensor data on a web page”) and the one attached. I’ve also attached the merged code i came out with and i need help on how to improve it. Basically what i was attempting to do was to create a sub routine for the calculation of my sensors and for it to be called upon constantly using the “while” in my loop program.

Mergedcode.ino (6.18 KB)

FlowMeterDIY.ino (3.85 KB)

What’s wrong with that implementation? What part doesn’t work?

A few things to consider:

  • Remove the attachInterrupt() and detachInterrupt() calls. Instead wrap the access to the counter variable inside cli()/sei() calls but keep it as short as possible:
uint8_t curr_counter;
cli();
curr_counter = counter;
counter = 0;
sei();
  • What’s the intention of this construct?
 bool (sensorCal()); {

Hello, the intention of bool (sensorCal()); { is for it to be a individual sub-routine to be called upon. I tried using void instead of bool but there seem to be an error. Currently for the merged code, it shows "client disconnected" in my serial monitor and i'm also unable to access the web server with the ip address. How do i go about removing attachInterrupt() and detachInterrupt() calls and wrapping the access access to the counter variable inside cli()/sei() calls but keep it as short as possible. Do i just delete every attachInterrupt() and detachInterrupt() i see and add the code u included?

Hello, the intention of bool (sensorCal()); { is for it to be a individual sub-routine to be called upon.

A subroutine call is made so:

 sensorCal();

No need for the boo() constructor and no need for the separate code block ({}).

How do i go about removing attachInterrupt() and detachInterrupt() calls and wrapping the access access to the counter variable inside cli()/sei() calls but keep it as short as possible. Do i just delete every attachInterrupt() and detachInterrupt() i see and add the code u included?

The former may work but you should try to understand the code not just copy/paste things together.

No, you cannot add the code I provided as that's just to show you how things work. The variable names don't match your code. Try to understand what the code you posted does, what my small excerpt does and then try to merge this. If that doesn't work, post your merged code and tell us what problems you have.