Help with esp32 sketch

OP
OP
A

andieasy

New Member
View Badges
Joined
Dec 15, 2019
Messages
21
Reaction score
36
Rating - 0%
0   0   0
I got it down to 1 error most the rest were fixed when i install python. Thank you for all you help Happy Holidays
/home/pi/Arduino/sketch_dec23a/sketch_dec23a.ino:3:10: fatal error: ESPAsyncWebServer.h: No such file or directory
#include <ESPAsyncWebServer.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

exit status 1

Compilation error: ESPAsyncWebServer.h: No such file or directory
Hello wolf, Merry Christmas as well.
im not the expert here, but it seems that you have not installed the library yet. i followed the guide from Sral, it really helps me with installing the firmware.
Alright, I hope you don't mind if I start building my guide here in your thread ^^

In steps:
  • Make sure you have the latest Arduino IDEinstalled (currently 2.0.3 at time of this guide)
    • if unsure, uninstall all Arduino IDEs and reinstall from the above link
  • Install the Arduino Core for the ESP32
    • Open the Arduino IDE and go to File->Preferences
    • under "Additional baords manager URLs" enter:
      • https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
      • You can separate several addresses there by using linebreaks or commas, as you can see here:
      • 1671113552443.png
      • click OK and open the Boards manager (yellow circle in the next picture) on the top left of the Arduino IDE and search for "espressif"
      • 1671121601584.png
      • install the "esp32 by Espressif Systems"
  • Install the necessary Libraries
    • Open the library manager (yellow circle in the next picture) and search for:
      • "DallasTemperature"
      • 1671122803678.png
      • install "Dallas Temperature by Miles Burton, etc."
      • search for "One Wire Studt"
      • 1671122998107.png
      • install "OneWire by Jim Studt, etc."
    • Now for the harder libraries:
  • Now to the ReefPi ESP32 code:
    • Make sure you have an empty Arduino sketch in front of you
    • Get ReefPi ESP32 code from here
      • (e.g. click the window, select ll by pressing CTRL+A, then copy by pressing CTRL+C)
    • Paste the code into the empty Arduino sketch
      • (e.g. click the open empty sketch, select all by pressing CTRL+A, then paste by pressing CTRL+V)
    • Select your ESP32 board at the top of the sketch:
    • 1671129587616.png
    • (Or for starters simply take the same one that I entered above)
    • Mine was a wroom chip:
    • 84A3D82B-CE57-4AC1-BFB0-9EE4AAF30A9C.jpeg
    • But the board is actualy a devkit v1:
    • 185729F5-E79D-42D6-85F0-8AA5BC8BF390.jpeg
    • Try compiling it to see if everything worked by pressing the tick-button in the top left:
    • 1671129833895.png
  • Now to connecting the ESP32 itself:
    • plug in your ESP32 using a proper data cable, I used the Raspberry Pi foundations cable for the Raspberry Pi Pico
    • you'll probably need to install a driver from the manufacturer of the USB communication chip
      • you can barely make out the name "SILABS" one the small 3x3mm chip in the bottom right of the above picture
      • strange installer Option here for me, extract the archive and right click the "silabser.inf" and select install:
      • 1671128197478.png
    • open "device-manager" in windows
      • look for Ports (COM & LPT):
      • 1671128276512.png
      • Note the Silicon Labs (SiLabs) USB to UART Bridge on COM4, remember that tag
    • in the Arduino IDE go to Tools->Board
      • directly below should an option "Ports":
      • 1671129923665.png
      • if "Ports" is not there, or you can't find the COM Port you found in the device manager, restart your PC. I had to do the same, afterwards I got the Port in the Arduino IDE
  • Now to flashing the ESP32:
    • open the example "Blink"
    • 1671129970806.png
    • a new window will open, make sure that it has the same board and COM-Port under "Tools"
    • click the arrow button in the top left to compile and upload, don't worry, compiling took quite a while at my end:
    • 1671130070846.png
    • You should see the Blue LED on the board starting to blink after the Output has finished and got to this:
    • 1671130128858.png
    • Now you're done connecting the ESP and we can go back to the ReefPi ESP32 code
i just following these steps, and i hope it can helps you as well. goodluck;)
 

Ranjib

7500 Club Member
View Badges
Joined
Apr 16, 2016
Messages
9,843
Reaction score
17,058
Location
Pleasant Hill, Concord
Rating - 0%
0   0   0
I got it down to 1 error most the rest were fixed when i install python. Thank you for all you help Happy Holidays
/home/pi/Arduino/sketch_dec23a/sketch_dec23a.ino:3:10: fatal error: ESPAsyncWebServer.h: No such file or directory
#include <ESPAsyncWebServer.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

exit status 1

Compilation error: ESPAsyncWebServer.h: No such file or directory
the readme covers links to library installation process. please go through it.
 

Wolfw28

Active Member
View Badges
Joined
Mar 13, 2022
Messages
201
Reaction score
139
Location
Myakka City
Rating - 0%
0   0   0
the readme covers links to library installation process. please go through it.
So 1 how do you configure temp on the one wire sensor on reefpi side for temp. I know it needs to be setup in the ph section but I’m kinda lost from there. 2 I take it unless I’m missing something but the pc version of Reefpi pi does not communicate with my pi. So just that mean I need to replace my pi with multiple ESP32. @Ranjib
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
So 1 how do you configure temp on the one wire sensor on reefpi side for temp. I know it needs to be setup in the ph section but I’m kinda lost from there. 2 I take it unless I’m missing something but the pc version of Reefpi pi does not communicate with my pi. So just that mean I need to replace my pi with multiple ESP32. @Ranjib
About 1: not sure yet, I’ll cover it in my guide and I hope to get to that tomorrow. Maybe @andieasy can help you in the meantime, he made it work in this post.
About 2: that’s how it was supposed to, as far as I know in order to circumvent the Raspberry PI shortage. Reef Pi runs on the PC and hardware interface is done with ESP32 or other compatible microcontrollers.
In principle though a Pi could, with the right software, perform the same tasks as the microcontroller, but I’m not sure if that will be something useful to many users.
 
OP
OP
A

andieasy

New Member
View Badges
Joined
Dec 15, 2019
Messages
21
Reaction score
36
Rating - 0%
0   0   0
hello @Sral and @Wolfw28 , sorry been kinda bussy lately, i forgot to reply your problem:beaming-face-with-smiling-eyes:.

1 )
1672474471045.png

you can see the sketch address onewirepin to pin4
1672474520250.png

and from the readme file, the default connector for its pin is 0.
so in connector setting you just need to set it to 0
1672474660766.png


for the board, you need to pull from pin 4 like this (its by default)
1672474762890.png


and then from pH setting you can set a new analog reading sensor based on the connector setting youve just setup (from my example, the analog sensor i named it: temp for driver esp32).
have a good try and let us know for any diffulties. (once again im not the expert here ;))

2. your point is correct. so i think Ranjib is aware about the problem of the shortage and expensive pi board nowadays, and thank him, he created the x86 version of reef-pi. it intends to connect directly from your pc through wifi connection. so if you already have a raspberry pi board, you dont need the esp32 actually, except for wireless controller like LED light (my idea is about to make one :beaming-face-with-smiling-eyes:)
 

Wolfw28

Active Member
View Badges
Joined
Mar 13, 2022
Messages
201
Reaction score
139
Location
Myakka City
Rating - 0%
0   0   0
hello @Sral and @Wolfw28 , sorry been kinda bussy lately, i forgot to reply your problem:beaming-face-with-smiling-eyes:.

1 )
1672474471045.png

you can see the sketch address onewirepin to pin4
1672474520250.png

and from the readme file, the default connector for its pin is 0.
so in connector setting you just need to set it to 0
1672474660766.png


for the board, you need to pull from pin 4 like this (its by default)
1672474762890.png


and then from pH setting you can set a new analog reading sensor based on the connector setting youve just setup (from my example, the analog sensor i named it: temp for driver esp32).
have a good try and let us know for any diffulties. (once again im not the expert here ;))

2. your point is correct. so i think Ranjib is aware about the problem of the shortage and expensive pi board nowadays, and thank him, he created the x86 version of reef-pi. it intends to connect directly from your pc through wifi connection. so if you already have a raspberry pi board, you dont need the esp32 actually, except for wireless controller like LED light (my idea is about to make one :beaming-face-with-smiling-eyes:)
@andieasy thank you. I didn’t quite understand your second point. You can or can’t get the raspberry pi to communicate with Reef-pi on pc.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
@andieasy thank you. I didn’t quite understand your second point. You can or can’t get the raspberry pi to communicate with Reef-pi on pc.
You can not
and I personally don’t think it likely that @Ranjib will make a ReefPi slave Software for raspberry PIs that enables this, at least not in the foreseeable future.

You will likely be able to use a Raspberry PI Pico W microcontroller instead of an ESP32 in the foreseeable future, since I think that should be fairly easy and I want to try coding this.
 
OP
OP
A

andieasy

New Member
View Badges
Joined
Dec 15, 2019
Messages
21
Reaction score
36
Rating - 0%
0   0   0
@andieasy thank you. I didn’t quite understand your second point. You can or can’t get the raspberry pi to communicate with Reef-pi on pc.
Sorry @Wolfw28 , my English is not very good.
The x86 version is intended to connect Linux (like Ubuntu) to esp32.
Due to the lack of GPIO pins in most modern PC, you need to add a microcontroller into it, so that you can interact the reef-pi with your tank.

While on the other hand, the raspberry pi board has GPIO pins by nature, that's why I said, we don't need the esp32 anymore if we already use raspberry pi board for reef pi.

You might already know bout it, once again sorry for my bad English.

Anyway how is the temp project? Did you succeed to make it work?:beaming-face-with-smiling-eyes:
 
Last edited:

Wolfw28

Active Member
View Badges
Joined
Mar 13, 2022
Messages
201
Reaction score
139
Location
Myakka City
Rating - 0%
0   0   0
Sorry @Wolfw28 , my English is not very good.
The x86 version is intended to connect Linux (like Ubuntu) to esp32.
Due to the lack of GPIO pins in most modern PC, you need to add a microcontroller into it, so that you can interact the reef-pi with your tank.

While on the other hand, the raspberry pi board has GPIO pins by nature, that's why I said, we don't need the esp32 anymore if we already use raspberry pi board for reef pi.

You might already know bout it, once again sorry for my bad English.

Anyway how is the temp project? Did you succeed to make it work?:beaming-face-with-smiling-eyes:
Thank you @andieasy got it working. Question how can I get temp to display in Fahrenheit. I take it that you can only have one temperature sensor per ESP 32. One last question my pH probe is. I2c so I take it that I can’t use that with the ESP 32.
 
OP
OP
A

andieasy

New Member
View Badges
Joined
Dec 15, 2019
Messages
21
Reaction score
36
Rating - 0%
0   0   0
Hi @Wolfw28
Glad that you finally did it.
1. Sorry bout the farenheit, because I'm using metrics, I never explore it
2. Interesting, you know theoretically we can have more temp because it is onewire. I will try add it as I have some more ds18 just coming recently.
3. I don't know about the probe, because I'm just using a cheap pH module which is analog reading.
Sorry I barely able to help you this time :beaming-face-with-smiling-eyes:
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Thank you @andieasy got it working. Question how can I get temp to display in Fahrenheit. I take it that you can only have one temperature sensor per ESP 32. One last question my pH probe is. I2c so I take it that I can’t use that with the ESP 32.
glad that worked out :)
1. there is a „transform function“ for pH values. Simply enter „1.8*v + 32“ and you will get Fahrenheit.
2. The code says something like „return all values by ID“, so I’m guessing that you can connect multiple sensors. I’ll test It as well for my guide.
3. Currently you can‘t, but both the ESP32 and the PI Pico have I2C capability, so I’ll try to implement this.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Finally !

Had a huge problem getting the ESP32 ready, because I could not debug properly. As it turns out, the standard pinDefinitions from @Ranjib use GPIO 1 as an INLET. Sadly, GPIO1 is also the UART Serial Pin, which means that as soon as you define GPIO1 as INLET, the Serial Connections I was using for debug no longer worked. Took me AGES to find that out :grinning-face-with-sweat:

I built a small demonstration circuit that uses all features. Since the ESP32 is rather large for a prototyping breadboard I had to hide a few components underneath it:
ReefPi_ESP32_Guide_Demo.jpg


All used Pins are labeled in Red on the translucent ESP32 board. I can try to get a better picture. Here is the circuit drawing:
ReefPi_ESP32_Guide_schem.png

3V3 and GND connected to the rails with red and black

On the right side:
  • One Wire Pin 4 is connected with purple wire
  • One Wire Pin 4 is pulled up to 3V3 with a 5k resistor
  • One Wire Signal, 3V3 and GND are connected to 2 JST connectors

  • OUTLET Pin 5 powers a LED through a 220 Ohm resistor
On the Bottom side of the breadboard and the left side of the drawing:
  • INLET Pin 36, fed with an analog 0 to 3.3V signal
    • (one could also connect an ATO signal here)

  • Analog Input Pin 32, fed with an analog 0 to 3.3V signal
    • (one could also connect a sensor signal here)

  • Jack Pin 12 and 27, feeding a 10µF capacitor over a 10k resistor each, generating an analog voltage from 0 to 3.3V depending on the PWM duty cycle from 0 to 100%
    • (one could also directly connect a lamp input to the Pin with a 200 Ohm resistor)

The GPIO Pins can be configured in the ESP32 script:
ReefPi_ESP32_Guide_PinDef.png


  • Modify the code as such:
    • First enter the number of respective Pins that you want. Make sure that this is the right number, as errors will result in crashes or non-functioning Pins !
    • Enter your WiFi info, e.g. WiFi name and password
    • Enter the GPIO-Numbers (example Pinout diagram) that you want to use for each purpose. Watch out for the following caveats:
      • if you want to use the Serial interface (UART) for debugging, don't use GPIO pins 1 and 3, as this will disable the Serial interface
      • GPIO 34-39 can only be used for INLET
        • they also have no internal pull-up or pull-down resistors
      • ADC2 Pins can NOT be used as Analog Inputs
        • only available when WiFi is off
  • Upload the code to your ESP32 (don't worry, compiling takes quite a while)
  • Start the Serial Monitor in the top right corner:
    • 1672675893169.png
  • In the bottom panel, klick "Serial Monitor" and set the Baudrate to 115200:
    • 1672675960581.png
    • restart the ESP32 by pressing the "EN" button on the front
  • if everything works, you should see something like this after a while:
    • 1672676004835.png
    • When using windows you can then open the command console with WIN+R and typing in "cmd" and pressing enter
    • type "ping" and afterwards the IP you just read and press enter:
    • 1672676102242.png
    • you should see some pings working with a time in the 100s of milliseconds
    • then type "arp -a" and press enter
    • You should see something like this:
    • 1672676187551.png
    • Note the "physical address" behind the previously encountered IP
    • You can set your router to give this physical address a constant IP if you like, in my case it looks something like this:
    • 1672676388996.png
    • I entered the physical address we noted before and the IP it should get
    • restart the ESP32 again by presing the "EN" button on the front
    • now I get this in the Serial Monitor:
    • 1672676583075.png
  • We now know the IP of the ESP32 and can continue to ReefPi
    • Go to Configuration->Drivers and add an ESP32 driver:
      • 1672676898170.png
      • Give it a nice name
      • enter the IP-address of the ESP32
      • enter the COUNT of OUTLET pins that you have entered in the code before
        • in my case I have the standard number of 6 outlets
        • proceed the same with INLET, PWM and Analog Input
    • go to Configuration->Admin and press reload
    • go to Configuration->Connectors and define your connections:
      • 1672677289451.png
      • Note that the "Pins" 0 to (Count-1) correspond to the order in the GPIO List we have defined in the ESP32 code:
      • 1672677454437.png
      • Since I connected my example to GPIO 36 I have to use Inlet "Pin" 2
      • Analog Inputs are special, since the Analog Input "Pin" 0 is always redirected to the DS18B20 OneWire protocol:
      • 1672677662940.png
      • That is why we had to increase the number of Analog Input in the driver by 1
      • The other Analog Inputs can then be accessed with "Pins" 1, 2, etc. once @Ranjib updated the code:
      • 1672677789975.png
      • Jacks work like OUTPUTS and INPUTS again, even though you have to manually type the pin number:
      • 1672677972263.png
    • Go to Configuration->Admin and Reload again
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Off to the fun part: testing !

  • Go to Equipment and define your Outlets:
    • 1672678231965.png
    • I had to go to Configuration->Admin and reload again to make it work
    • afterwards I can switch the LED on and off:
    • Reef_Pi_ESP32_Guide_OUTLET_LED.jpg
    • which also get's printed to the Serial Monitor:
    • 1672678302588.png
  • Go to "pH"
    • define your temperature sensor:
      • 1672678912444.png
      • I have used a very low interval to get faster results
      • Serial Monitor should print something like this:
      • 1672678982835.png
      • if you want Fahrenheit instead, enter this transform function:
      • 1672682426848.png
    • define your Analog Input:
      • 1672679053943.png
      • enter the following rough transform function:
      • 1672680522209.png
      • You should afterward see this in the Serial Monitor:
      • 1672679428863.png
      • e.g. voltage is 0
  • Go to "ATO" and define your inlets:
    • 1672678821447.png
    • in my case I set interval very low so I can see it quickly
    • afterwards you should see a regular result in the Serial Monitor:
    • 1672678506696.png
  • go to "lights" and define your jacks:
    • 1672679521783.png
    • I switched mine to manual for testing
    • When I increase the Duty Cycle to 10%:
    • 1672679598877.png
    • I get this in the Serial Monitor:
    • 1672679639627.png
    • You can see the regular commands to increase Duty Cycle on Pin 12 up to a value of 25
    • When I go to the pH Tab and look at the measurement I get:
    • 1672679712054.png
    • The voltage on the left of the step is actually 0, but we can't measure that without more clever signal electronics, so it reads a constant 0.14
    • The voltage after increasing duty cycle to 10% increases to 0.34V or about a tenth of the full 3.3V
    • When I then go to 90% and slowly increase in 1% steps to 100% you see that the top is wrong as well:
    • 1672680117472.png
    • at about 96% the result stays at 3.51, even though it should rise further, like the dotted line and it is also slightly wrong at 3.51V instead of 3.3V
    • Without more intelligent signal electronics, one can only reliably measure voltages between 0.15V and 2.32V
    • At 50% duty cycle you do however get a nice 1.65V as expected
  • I can also test the INLET:
    • If I increase the duty cycle on the respective "light" that increases the voltage on the Input Pin to 100% I get an ATO signal:
    • 1672681749668.png

Hope that helps. There are a few things to work on, e.g.
  • the Analog Input is a bit lackluster
    • I can design a simple input circuit with a few resistors and an OP-Amp that will remedy this
  • The ESP32 software will probably receive some extensions in the future
    • a safer interface for dosers, e.g. a maximum dose time in case of WiFi failure
    • currently one cannot have multiple DS18B20 sensors per ESP32
      • that can be extended through software in the future
    • Currently there is a bug with DS18B20 sensors and Analog Inputs
      • that will be fixed in the future
    • an I2C interface for at least @robsworld78's pH circuit
 

Wolfw28

Active Member
View Badges
Joined
Mar 13, 2022
Messages
201
Reaction score
139
Location
Myakka City
Rating - 0%
0   0   0
Off to the fun part: testing !

  • Go to Equipment and define your Outlets:
    • 1672678231965.png
    • I had to go to Configuration->Admin and reload again to make it work
    • afterwards I can switch the LED on and off:
    • Reef_Pi_ESP32_Guide_OUTLET_LED.jpg
    • which also get's printed to the Serial Monitor:
    • 1672678302588.png
  • Go to "pH"
    • define your temperature sensor:
      • 1672678912444.png
      • I have used a very low interval to get faster results
      • Serial Monitor should print something like this:
      • 1672678982835.png
      • if you want Fahrenheit instead, enter this transform function:
      • 1672682426848.png
    • define your Analog Input:
      • 1672679053943.png
      • enter the following rough transform function:
      • 1672680522209.png
      • You should afterward see this in the Serial Monitor:
      • 1672679428863.png
      • e.g. voltage is 0
  • Go to "ATO" and define your inlets:
    • 1672678821447.png
    • in my case I set interval very low so I can see it quickly
    • afterwards you should see a regular result in the Serial Monitor:
    • 1672678506696.png
  • go to "lights" and define your jacks:
    • 1672679521783.png
    • I switched mine to manual for testing
    • When I increase the Duty Cycle to 10%:
    • 1672679598877.png
    • I get this in the Serial Monitor:
    • 1672679639627.png
    • You can see the regular commands to increase Duty Cycle on Pin 12 up to a value of 25
    • When I go to the pH Tab and look at the measurement I get:
    • 1672679712054.png
    • The voltage on the left of the step is actually 0, but we can't measure that without more clever signal electronics, so it reads a constant 0.14
    • The voltage after increasing duty cycle to 10% increases to 0.34V or about a tenth of the full 3.3V
    • When I then go to 90% and slowly increase in 1% steps to 100% you see that the top is wrong as well:
    • 1672680117472.png
    • at about 96% the result stays at 3.51, even though it should rise further, like the dotted line and it is also slightly wrong at 3.51V instead of 3.3V
    • Without more intelligent signal electronics, one can only reliably measure voltages between 0.15V and 2.32V
    • At 50% duty cycle you do however get a nice 1.65V as expected
  • I can also test the INLET:
    • If I increase the duty cycle on the respective "light" that increases the voltage on the Input Pin to 100% I get an ATO signal:
    • 1672681749668.png

Hope that helps. There are a few things to work on, e.g.
  • the Analog Input is a bit lackluster
    • I can design a simple input circuit with a few resistors and an OP-Amp that will remedy this
  • The ESP32 software will probably receive some extensions in the future
    • a safer interface for dosers, e.g. a maximum dose time in case of WiFi failure
    • currently one cannot have multiple DS18B20 sensors per ESP32
      • that can be extended through software in the future
    • Currently there is a bug with DS18B20 sensors and Analog Inputs
      • that will be fixed in the future
    • an I2C interface for at least @robsworld78's pH circuit
Thank you for all your hard work.1 Question will @robsworld78 flowmeter script work with the ESP32 analog input and in the ph transform be able to convert my (F) on the flow meters. Basically i'm got 4 flow sensors i have in the script gpm and the (F) 4.5 but have to others that are (5.5) can that be converted in the ph transform. 2 could you provide when you get a chance wire diagram of flow sensor attached to the ESP32 i know vcc and ground but do i need any restores or compactor. Thank you again.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Thank you for all your hard work.1 Question will @robsworld78 flowmeter script work with the ESP32 analog input and in the ph transform be able to convert my (F) on the flow meters. Basically i'm got 4 flow sensors i have in the script gpm and the (F) 4.5 but have to others that are (5.5) can that be converted in the ph transform. 2 could you provide when you get a chance wire diagram of flow sensor attached to the ESP32 i know vcc and ground but do i need any restores or compactor. Thank you again.
Oh, completely forgot about that !
The script won’t work on the x86, but needs to be included on the ESP32, which is easy ! I’ll Programm that as well, the transform function will absolutely be able to account for all of the different flow constants.

You simply have to connect the flow meter to 5V, GND and the signal will need to be reduced to 3.3V using two resistors, like @robsworld mentioned here:
1672818116258.png

It’s important that the GPIO sees only 3.3V (or 3.6 to 2.8V if you don’t have fitting resistors) from the full 5V that the flowmeter signal has. You can alternatively use an Adafruit BSS138 level shifter, that works as well.
 
Last edited:

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Ha ! Got the flowmeter code working on the ESP32. I simply fed it the 5kHz PWM from a jack and as you can see:
1672859183203.png

Counts absolutely nicely ^^

I'll try the robsworld pH circuit on I2C as well and push the code to GitHub.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
@Ranjib I also managed to analyze the backlog from 4 of my crashes on the ESP32. Its modified code, but maybe it helps us:

1672866182080.png

In all 4 cases the error occured on the same spot in the AsyncTCP package.
These are taken from my adapted version for the flowmeter, so I have an interrupt running that could possibly interfere.

I got these reports from using the xtensa-esp32-elf-addr2line.exe where Arduino saves the board packages. Give this exe the compiled elf file of the sketch (in my case located in appdata/local/temp/ ... />>sketchname<<.ino.elf) and the backlog.
 

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
Hm, seems like @robsworld78's pH circuit isn't as easy to interface as I thought ...

Here's the code:
1672945951368.png

And here's the answer:
1672945924637.png


So the pH circuit recognizes it's address and the "data" (e.g. the "read"-command), as visible by the errorcode "0" after transmitting. I previously got an error here, but was able to solve this.
However, I don't get any data back. I'm a bit puzzled.

I tried both baudrates of 10 and 100 kHz, with and without 100ms delay between command and request, as well as increased bus timeout of 100 ms, which should allow the circuit it's clock stretching.
 
Last edited:

Sral

Valuable Member
View Badges
Joined
May 2, 2022
Messages
1,006
Reaction score
976
Location
Germany
Rating - 0%
0   0   0
For completeness, here is the cabling. I have set the circuit to 3.3V and connected 3.3V to it. Pull-up is done with one 3.4k resistor on each SDA and SCL.
SDA and SCL are connected to the Default pins for I2C: Nr 21 and 22
D9AC1067-DD0B-402E-8583-4A771C9AB48E.jpeg
 

Reefing threads: Do you wear gear from reef brands?

  • I wear reef gear everywhere.

    Votes: 42 16.4%
  • I wear reef gear primarily at fish events and my LFS.

    Votes: 16 6.3%
  • I wear reef gear primarily for water changes and tank maintenance.

    Votes: 1 0.4%
  • I wear reef gear primarily to relax where I live.

    Votes: 30 11.7%
  • I don’t wear gear from reef brands.

    Votes: 148 57.8%
  • Other.

    Votes: 19 7.4%
Back
Top