DIY Alkalinity Monitor

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
Ok I've received a message in serial "Couldn't connect to server" and then ESP Restarted , this a good sign i will start looking from here
 

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
here is the log in serial monitor

22:46:06.199 ->
22:46:21.128 -> could not connect to server
 

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
I made a test sketch just to send emails to make sure that GMAIL and ESP are not having issues and it works now i have to figure out what's causing the issue in the code .

Test mail recieved.png Test Sketch.png
 

Attachments

  • Test sketch.txt
    3.2 KB · Views: 25

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
here is the current error
01:10:53.383 -> Connecting to SMTP server...
01:11:06.764 -> Error, could not connect to server
01:11:06.764 -> Error while sending email, could not connect to server
01:11:06.811 ->

the problem is in here

String sendEmail(char *subject, char *sender, char *body, char *recipient, boolean htmlFormat) {
Serial.println("Sending email...");
smtpData.setLogin(GMAIL_SMTP_SEVER, GMAIL_SMTP_PORT, GMAIL_SMTP_USERNAME ,
GMAIL_SMTP_PASSWORD);
smtpData.setSubject(subject);
smtpData.setSender(sender, GMAIL_SMTP_USERNAME);
smtpData.addRecipient(recipient);
smtpData.setMessage(body, htmlFormat);
 
Last edited:

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
Thanks God , i commented below lines and it worked .

// IPAddress local_IP(192, 168, 1, 111);
// IPAddress gateway(192, 168, 1, 254);
// IPAddress subnet(255, 255, 255, 0);
// IPAddress primaryDNS(8, 8, 8, 8); //optional
// IPAddress secondaryDNS(8, 8, 4, 4); //optional


void Setup()
// if (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
// Serial.println("STA Failed to configure");
// }


So please dear @Borat do I really need these lines are they going to cause any issues if left commented

Successfull email sending.png Untitled.png
 
Last edited:
OP
OP
Borat

Borat

Valuable Member
View Badges
Joined
Apr 4, 2021
Messages
1,491
Reaction score
1,724
Location
United Kingdom
Rating - 0%
0   0   0
another question , why am always receiving this warning "Acid priming failed"
Can you upload your ESP32 code please (remove all username and passwords surely!)..

I prime acid line a bit - as a precaution. It's done by adding 0.5ml of acid to the reaction chamber (before the test) - and checking if PH dropped by a certain amount of PH points (and if not - you may have ran out of reagent OR you have other problems, such as your reaction chamber is empty or your acid line tubing has a leak and it's not full). If you are using acid that is more dilutated, you should prime the acid line with a bit more acid (1ml?) or test for a lower PH drop (0.05PH?)?

This is not a strictly speaking a neceassary step and priming can be left out...

There is also a separate menu item called "Prime" - this is used in sutiations where you disconnected the acid container (say for refilling) and want to re-fill the acid tubing.. I normally do it in a few goes, i.e. select that menu a couple of times to achieve the result..
 

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
Can you upload your ESP32 code please (remove all username and passwords surely!)..

I prime acid line a bit - as a precaution. It's done by adding 0.5ml of acid to the reaction chamber (before the test) - and checking if PH dropped by a certain amount of PH points (and if not - you may have ran out of reagent OR you have other problems, such as your reaction chamber is empty or your acid line tubing has a leak and it's not full). If you are using acid that is more dilutated, you should prime the acid line with a bit more acid (1ml?) or test for a lower PH drop (0.05PH?)?

This is not a strictly speaking a neceassary step and priming can be left out...

There is also a separate menu item called "Prime" - this is used in sutiations where you disconnected the acid container (say for refilling) and want to re-fill the acid tubing.. I normally do it in a few goes, i.e. select that menu a couple of times to achieve the result..
Thank you so much . Your answer is quit enough regarding acid priming , i will increase the volume to 1ml,

Regarding uploading the code sure will do once i get back home ...


I was trying to make something else earlier today but failed unfortunately, i was trying to switch between wifi modes from station to access point incase no connection available and to open an html once access point connection established to add your home wifi credentials then store these data in struct in EEPROM . The logic looks fine and it should work but i can't get my esp to catch Access point connection. doono why may be because i played alot with my ESP firmware and flashed its software to revive it back from brick mode . Any how its working now perfectly but i may have something wrong with the code related to access point . Will share this code as well
 
Last edited:

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
Hello @Borat , here you go the codes ,
the one that uses both wifi modes is unstable after merging the Alk codes with it , donno why it crashes after connecting to network however if you removed all coded related to this project it will work the only drawback is it writes to the EEPROM and i believe it will be way better to find a temp memory to store data to or firebase database , but am so tired to look for it may be you can if you have time of course
 

Attachments

  • KH with both wifi modes (crashes and unstable).txt
    9.8 KB · Views: 33
  • KH_Guardian_Hardcoded_SSID.txt
    6.4 KB · Views: 30
OP
OP
Borat

Borat

Valuable Member
View Badges
Joined
Apr 4, 2021
Messages
1,491
Reaction score
1,724
Location
United Kingdom
Rating - 0%
0   0   0
A bit of a background, FYI.. 2-way communication link between arduino and ESP32 devices has never been intended by its creators.. what you see as a 2-way link in my code is a bit of a creative workaround..

Generally I2C communication works pretty well in all circumstances (Wire.begin(WIRE_SLAVE_ADDRESS); Wire.onReceive(receiveEvent); ), the problem of employing this as a 2-way communication method is that I2C communication is only intended to be 1-way, there are potentially multiple slave devices but only a single master and communication is from master to slaves. Slaves and master can flip their roles though - potentially you can design the code where a message sent by master means that the slave on the opposite side will become master and master will downgrade itself to slave..

So I kind of solved it by employing RX/TX serial communication link to enable communication back from ESP32 to Arduino - but it is not very reliable and data is not always received. It is an asynchronous communication, you might be sending data from ESP32 just as Arduino was doing something else - and it may sometimes lead to both devices freezing..

So if I were you, I would first experiment with how well this 2-way communication works and also find out under what conditions it starts to break. Maybe when the motor starts to spin, you get lower voltagae? Maybe when the motor starts to spin your device is not responsive? I don't know - but you can only solve it if you start with basics..
 

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
Hello again my friend @Borat after changing the RX , TX pins 2 ways communication working fine with me , Mega is sending data to ESP and ESP replies to Mega by ntp time . So now 2 ways communications is not an issue with me anymore .

As for the emails notifications from ESP also working great

But when tweaking the part related to capture wifi credentials as a variable not constant i noticed that there are a lot of conditions that might cause the logic to fail . Sometimes the MCU catches the credentials and simply connects using given data and sometimes not .

Also sometimes goes into idle state while connecting and not reacting to reconnect command these are the issue i faced with ESP .

I have an idea inwhich i will store wifi credentials to a firebase and give it a try but this is not priority now . Yet if this concept works well i will be able to communicate smoothly between mobile app and ESP and Mega will receive messeges from ESP according using slave wire .

I will post here the sdk of the mobile app for you and lets give it a try . What do you think
 

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
Hi @Borat and anyone with debugging skills , i fixed the version where ESP connects to Wifi and if failed will switch to access point mode to enter the default local ip using your internet browser to set your home wifi credentials . once credentials saved device will restart and switch back to normal wifi mode "station" but when it reaches the part where it should send email it crashes . not sure why ? so need your help here please
 

Attachments

  • KH with both wifi modes - working but crashes at the sending emails .txt
    10.5 KB · Views: 21

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
@Borat i have bought a brand new ESP the same model i had before just to test why serial communication not working when settings the UART as follows and still not working .. am wondering do you use the same ESP model if yes have you modified the
Configuration.h file

RX0 , TX0 are occupied by Programming port in ESP32 so how did you managed to use them

so this line never work with me and works with you

Serial.begin(115200);
// Serial2.begin(9600, SERIAL_8N1, 16, 17);
Serial2.begin(9600, SERIAL_8N1, 3, 1);
 

Attachments

  • ESP32-Pinout.png
    ESP32-Pinout.png
    39.1 KB · Views: 24
OP
OP
Borat

Borat

Valuable Member
View Badges
Joined
Apr 4, 2021
Messages
1,491
Reaction score
1,724
Location
United Kingdom
Rating - 0%
0   0   0
@Borat i have bought a brand new ESP the same model i had before just to test why serial communication not working when settings the UART as follows and still not working .. am wondering do you use the same ESP model if yes have you modified the
Configuration.h file

RX0 , TX0 are occupied by Programming port in ESP32 so how did you managed to use them

so this line never work with me and works with you

Serial.begin(115200);
// Serial2.begin(9600, SERIAL_8N1, 16, 17);
Serial2.begin(9600, SERIAL_8N1, 3, 1);
This looks like a Dev board - same as I use.. Let me look into your issue a bit more carefully..
 

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
This looks like a Dev board - same as I use.. Let me look into your issue a bit more carefully..
Thank you so much . This issue is driving me crazy, and am not comfortable pending new board pins to use TX2, RX2 pins
 

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
OK @Borat here is how I fixed it .

Serial.begin(115200);//, SERIAL_8N1, 16, 17);
Serial2.begin(9600, SERIAL_8N1, 3, -1,false);
Wire.begin(SDA,SCL);
while (!Serial2) delay(1000);


however I tested sending strings from ESP to Mega : Message received and vise versa

I tried to change the time manually to very old time and date hoping to be updated automatically but this didn't happened , not sure why .

I believe time update should take place twice a day at 6AM , 6PM yet it should compare time if first time start condition is true then get time from RTC , Then LCD displayed time will be updated accordingly .
 

Attachments

  • Untitled.png
    Untitled.png
    161.8 KB · Views: 23

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
OK time update solved and reflected to LCD but donno if this was the solution or not .

at the beginning of the setup()
while (!Serial2) delay(10);

1685492967636.png
 

BassamKassem

Active Member
View Badges
Joined
Mar 8, 2023
Messages
154
Reaction score
60
Location
Egypt
Rating - 0%
0   0   0
One favour plz from anyone here whom successfully completed this amazing project. I need a video from the reaction chamber that shows the cortex when stirrer starts.

Also need the exact size of the Stir magnet bar .

Mine is 1CM and not making vortex effect at all but it spins normally with good speed i think

Screenshot_20230531-190154_WhatsApp.jpg
 

cliffE

Community Member
View Badges
Joined
Mar 31, 2023
Messages
84
Reaction score
56
Location
Alaska
Rating - 0%
0   0   0
One favour plz from anyone here whom successfully completed this amazing project. I need a video from the reaction chamber that shows the cortex when stirrer starts.

Also need the exact size of the Stir magnet bar .

Mine is 1CM and not making vortex effect at all but it spins normally with good speed i think

Screenshot_20230531-190154_WhatsApp.jpg

 
Last edited:

cliffE

Community Member
View Badges
Joined
Mar 31, 2023
Messages
84
Reaction score
56
Location
Alaska
Rating - 0%
0   0   0
I don't get a vortex either. I don't think it is a super big deal. If you are worried about mixing I wonder if you can adjust the code so it stirs longer.
 

High pressure shells: Do you look for signs of stress in the invertebrates in your reef tank?

  • I regularly look for signs of invertebrate stress in my reef tank.

    Votes: 35 31.3%
  • I occasionally look for signs of invertebrate stress in my reef tank.

    Votes: 26 23.2%
  • I rarely look for signs of invertebrate stress in my reef tank.

    Votes: 21 18.8%
  • I never look for signs of invertebrate stress in my reef tank.

    Votes: 30 26.8%
  • Other.

    Votes: 0 0.0%
Back
Top