Hi all,
In the support video for the Piicodev Airquality sensor (with Micro:bit), at 10:17 the plotter (Python in Thonny) is functioning. How can I get data visualised in the plotter and is it possible to export data?
Many thanks from this newbie.
Hi all,
In the support video for the Piicodev Airquality sensor (with Micro:bit), at 10:17 the plotter (Python in Thonny) is functioning. How can I get data visualised in the plotter and is it possible to export data?
Many thanks from this newbie.
Assume you would like some graphs like the ones shown in the guide. (see below)
So there is two parts to this, first collect the data, second display the data.
The plotter in Thonny is ok, but not useful for what you want to do.
First collect the data.
How the sensor readings are saved would need to be decided, Micro SD card or USB stick or something else. Maybe just in the memory of the recording device, Micro:Bit. Then the format of the data would need to be decided, CSV format can be input into any standard spreadsheet application. If it was just in the recording device then the format would depend on how it was going to be displayed. The Micro:Bit has limited ability to save information and display it on a screen.
Second display that data.
What would be used to display the data, PC screen, Tablet, Phone or the device doing the recording with a display attached.
In my opinion the Micro:Bit is not the best device to use, a Raspberry Pi would be better as it has screen keyboard mouse USB Ethernet & WiFi interfaces built in. And the OS is a proper Linux system. The PiicoDev Air Quality Sensor would connect via the I2C adaptor board made by Core Electronics. Just plug it in and it works.
I am currently using a RPi 3B+ to collect weather data from a number of sensors (Air Quality being one of them) and display it as a Web page. The Raspberry Pi performs very well.
If you need more information happy to help.
Regards
Jim
Thanks so much, Jim. Yes - RPi seems a better tool for the job now. Unfortunately, I am stuck with the Micro:bit and just assumed from the Core video guide example that the plotter would be activated within the downloaded code.
I’m after an idea of how to get the Thonny plotter working, unless there is a better Python IDE for the purpose.
I will try reducing the sensing to one element as in the example, and see how that goes…
Thanks again.
Thonny is the best IDE I have found for Python so far.
The following program is a modification of the code in the guide, it has been tested with the Air Quality Sensor and a RPi Pico. (see screen shot)
The plotter in Thonny looks at print statements and produces a graph, there is no ability to adjust it, the plotter choose the scale it thinks is best. The changes in the graph were produced by blowing on the sensor to change the CO2 level.
# Read air quality metrics from the PiicoDev Air Quality Sensor ENS160
# Shows three metrics: AQI, TVOC and eCO2
from PiicoDev_ENS160 import PiicoDev_ENS160 # import the device driver
from PiicoDev_Unified import sleep_ms # a cross-platform sleep function
sensor = PiicoDev_ENS160() # Initialise the ENS160 module
while True:
# Read from the sensor
aqi = sensor.aqi.value
tvoc = sensor.tvoc
eco2 = sensor.eco2.value
# print('AQI : ',aqi,'TVOC: ',tvoc,'eCO2: ',eco2)
print('TVOC: ',tvoc,'eCO2: ',eco2)
sleep_ms(500)
Cheers
Jim
Thanks Jim - that makes so much sense. Unfortunately, I appear to have fried my brand new micro:bit and over 5 hours of trying every fix I could find, has not worked. I think tears are a sign I need to just stop and watch some cute dog videos… I will try out on a student’s device on Monday.
The support from CE is aMAzing! Thanks so much.
Thank you @James46717 for helping get this sorted!
If you need any more help @Jane278324, Please let us know