Hello everyone. I have a request for all the experts on this forum. I have a task to extract one piece of information from a page indicating the height of a river. This is used for a hydroelectric power plant. We have sensors but sometimes they fail and we want to download information from a government page. The obtained information will be sent by modbus tcp to the PLC controller. I have already solved this communication. But I can't extract the water level. I tried for 2 days but somehow without success. I am not an expert in Arduino but someone will certainly be able to help in such a simple matter. I am posting a link to the page and I only need the state of the height of the river. - River Aire level at Chapel Haddlesey - GOV.UK.
Thank you in advance for the help you have given me.
Regards Norbert
This is not an API, but just a webpage.
If you want, you can grab level from the HTML of webpage, but why when you have full and free real API?
Here you can find all information needed:
For example, in order to get detailed info about the station pointed from your link you can call this API endpoint wich provide a JSON
What have you tried so far?
Can you share the code?
Where on the page is the height mentioned? (OK found 0m on the left)
The most interesting part imho is " your feedback will help us to improve it."
Giving them the feedback that you want e.g. an API that produces a JSON file from which you can extract your needed data is probably the way to go.
No need to ask, the APIs are already available.
@cotestatnt
Missed your post, sorry!
Shorter URL (=> process less json)
https://environment.data.gov.uk/flood-monitoring/id/measures/L1803-level-stage-i-15_min-m
Thanks for the quick replies. I do have : https://environment.data.gov.uk/hydrology/id/measures/f1f0dd95-9c6d-47cc-89f5-f342ee1be03d-level-i-900-m-qualified/readings.json?latest... that's what one person suggested to me. Now how to extract just that one piece of information through API or Json. The code that I could send is not suitable for showing because it's some kind of a conglomeration that I thought would work but doesn't.. I used examples from the internet. I tried with ArduinoJson Assistant but it seems to be to much for my head. Instead of reinventing the wheel I decided to ask on the forum if anyone has done something like that before. It would save me a lot of time. And I'll learn something new in the process.
This link only contains the latest measurement and lacks station information. It's just a few bytes smaller than the one provided by @robtillaart. I’d stick with his suggestion, as it’s more readable.
Parsing JSON is quite straightforward using a well-known library like ArduinoJson.h.
With the help of the online assistant, you can paste your JSON, and it will suggest the appropriate way to deserialize it and extract the necessary information.
You didn't specify which MCU you're using, so I'll assume it's an ESP32 for this example:
Hi @cotestatnt
I created a copy of your WOKWI-Simulation.
And added some more serial printing to make visible how the received data looks like
but in this copy I only get an error-message.
Do you have a paid plan for WOKWI?
This is the serial output from my copy
ts Jul 29 2019 12:21:46
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1156
load:0x40078000,len:11456
ho 0 tail 12 room 4
load:0x40080400,len:2972
entry 0x400805dc
Connecting to WiFi................................................................................................................................................................................................................................ Connected!
IP=10.10.0.2
Fetching https://environment.data.gov.uk/flood-monitoring/id/measures/L1803-level-stage-i-15_min-m...
Error code: -1
:-(
Hi @StefanL38
No, unfortunately I don't have a paid plan.
I've encountered the same issue a few times, but after trying again, it eventually worked.
I can only assume it's due to wokwi server load, since it works flawlessly every time with a real ESP32.

