{"id":3427,"date":"2026-10-30T13:58:26","date_gmt":"2026-10-30T13:58:26","guid":{"rendered":"https:\/\/www.robertprice.co.uk\/robblog\/?p=3427"},"modified":"2026-10-30T13:58:26","modified_gmt":"2026-10-30T13:58:26","slug":"rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014","status":"publish","type":"post","link":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/","title":{"rendered":"RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In my last post, I showed <a href=\"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-4-reading-the-temperature-from-a-bme280-on-an-rc2014\/\">how to read the temperature from a BME280 sensor using a Z80-based RC2014 computer<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The BME280 can also provide readings for humidity and atmospheric pressure. In this post, I&#8217;m going to look at reading humidity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The BME280 provides the humidity value as a 24bit integer. I can use the read24 function I defined in my last post to read this value from the BME280. However, I can&#8217;t use it directly. Like the temperature reading, I have to do some calculations using the calibration data from the BME280. Thankfully, the <a href=\"https:\/\/www.bosch-sensortec.com\/media\/boschsensortec\/downloads\/datasheets\/bst-bme280-ds002.pdf\">BME280 datasheet<\/a> gives me an algorithm to do this on page 25, so I just need to tweak this to drop in the relevant values.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>float readHumidity(void) {\n    int32_t adc_H = read16(BME280_REGISTER_HUMIDDATA);\n    int32_t v_x1_u32r;\n\n    v_x1_u32r = (t_fine - ((int32_t)76800));\n    v_x1_u32r = (((((adc_H &lt;&lt; 14) - (((int32_t)_bme280_calib.dig_H4) &lt;&lt; 20) -\n                    (((int32_t)_bme280_calib.dig_H5) * v_x1_u32r)) +\n                   ((int32_t)16384)) >>\n                  15) *\n                 (((((((v_x1_u32r * ((int32_t)_bme280_calib.dig_H6)) >> 10) *\n                      (((v_x1_u32r * ((int32_t)_bme280_calib.dig_H3)) >> 11) + ((int32_t)32768))) >>\n                     10) +\n                    ((int32_t)2097152)) *\n                       ((int32_t)_bme280_calib.dig_H2) +\n                   8192) >>\n                  14));\n    v_x1_u32r =\n        (v_x1_u32r -\n         (((((v_x1_u32r >> 15) * (v_x1_u32r >> 15)) >> 7) *\n           ((int32_t)_bme280_calib.dig_H1)) >>\n          4));\n    v_x1_u32r = (v_x1_u32r &lt; 0 ? 0 : v_x1_u32r);\n    v_x1_u32r = (v_x1_u32r > 419430400 ? 419430400 : v_x1_u32r);\n    return (float)(v_x1_u32r >> 12) \/ 1024.0;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">I can now simply tweak my main() function to query this and display the results to the console.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>float humidity = readHumidity();\nprintf(\"Humidity: %.2f %%\\n\", humidity);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That was really simple because most of the hard work had already been done in my previous post. The <code>readHumidity<\/code> function looks complex, but it&#8217;s just the example code from the datasheet tweaked to use my variables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my last post, I showed how to read the temperature from a BME280 sensor using a Z80-based RC2014 computer. The BME280 can also provide readings for humidity and atmospheric pressure. In this post, I&#8217;m going to look at reading humidity. The BME280 provides the humidity value as a 24bit integer. I can use the &hellip; <a href=\"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":3387,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[157,209,187],"tags":[215,117,219],"class_list":["post-3427","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-rc2014","category-rc2026","category-retrochallenge","tag-bme280","tag-rc2014","tag-rc2026"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014 - Robert Price<\/title>\n<meta name=\"description\" content=\"Getting the humidity using an BME280 attached to an Z80-based RC2014 computer.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014 - Robert Price\" \/>\n<meta property=\"og:description\" content=\"Getting the humidity using an BME280 attached to an Z80-based RC2014 computer.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/\" \/>\n<meta property=\"og:site_name\" content=\"Robert Price\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-30T13:58:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.robertprice.co.uk\/robblog\/assets\/BME280-RC2014.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"1200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"rob\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rob\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/\"},\"author\":{\"name\":\"rob\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"headline\":\"RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014\",\"datePublished\":\"2026-10-30T13:58:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/\"},\"wordCount\":188,\"image\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/BME280-RC2014.jpg\",\"keywords\":[\"BME280\",\"RC2014\",\"RC2026\"],\"articleSection\":[\"RC2014\",\"RC2026\",\"RetroChallenge\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/\",\"name\":\"RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014 - Robert Price\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/BME280-RC2014.jpg\",\"datePublished\":\"2026-10-30T13:58:26+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"description\":\"Getting the humidity using an BME280 attached to an Z80-based RC2014 computer.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/BME280-RC2014.jpg\",\"contentUrl\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/assets\\\/BME280-RC2014.jpg\",\"width\":1600,\"height\":1200},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\",\"name\":\"Robert Price\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\",\"name\":\"rob\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"caption\":\"rob\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014 - Robert Price","description":"Getting the humidity using an BME280 attached to an Z80-based RC2014 computer.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/","og_locale":"en_GB","og_type":"article","og_title":"RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014 - Robert Price","og_description":"Getting the humidity using an BME280 attached to an Z80-based RC2014 computer.","og_url":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/","og_site_name":"Robert Price","article_published_time":"2026-10-30T13:58:26+00:00","og_image":[{"width":1600,"height":1200,"url":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/BME280-RC2014.jpg","type":"image\/jpeg"}],"author":"rob","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rob","Estimated reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/#article","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/"},"author":{"name":"rob","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"headline":"RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014","datePublished":"2026-10-30T13:58:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/"},"wordCount":188,"image":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/#primaryimage"},"thumbnailUrl":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/BME280-RC2014.jpg","keywords":["BME280","RC2014","RC2026"],"articleSection":["RC2014","RC2026","RetroChallenge"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/","url":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/","name":"RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014 - Robert Price","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/#primaryimage"},"image":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/#primaryimage"},"thumbnailUrl":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/BME280-RC2014.jpg","datePublished":"2026-10-30T13:58:26+00:00","author":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"description":"Getting the humidity using an BME280 attached to an Z80-based RC2014 computer.","breadcrumb":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/#primaryimage","url":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/BME280-RC2014.jpg","contentUrl":"https:\/\/www.robertprice.co.uk\/robblog\/assets\/BME280-RC2014.jpg","width":1600,"height":1200},{"@type":"BreadcrumbList","@id":"https:\/\/www.robertprice.co.uk\/robblog\/rc2026-part-5-reading-the-humidity-from-a-bme280-on-an-rc2014\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.robertprice.co.uk\/robblog\/"},{"@type":"ListItem","position":2,"name":"RC2026 \u2013 Part 5 \u2013 Reading the humidity from a BME280 on an RC2014"}]},{"@type":"WebSite","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website","url":"https:\/\/www.robertprice.co.uk\/robblog\/","name":"Robert Price","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.robertprice.co.uk\/robblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5","name":"rob","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","caption":"rob"}}]}},"_links":{"self":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/3427","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/comments?post=3427"}],"version-history":[{"count":1,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/3427\/revisions"}],"predecessor-version":[{"id":3429,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/3427\/revisions\/3429"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media\/3387"}],"wp:attachment":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media?parent=3427"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/categories?post=3427"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/tags?post=3427"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}